def remove_all_file(filepath, file_name):
"""
删除 MAC 临时文件
:param file_name:
:return:
"""
for root, dirs, files in os.walk(filepath):
for name in files:
print(name)
if name.startswith("._") or name == file_name:
os.remove(os.path.join(root, name))
接着,我们利用pyinstaller将Python文件打包成Exe可执行文件。 1 V: Y. l1 l8 u0 b- _
# 安装 pyinstaller ( c. Q, X* B t W4 bpip3 install pyinstaller 8 D. s, D, j+ t2 e9 D# 把 py 文件打包成 exe 可执行文件 # M# B9 A- H% i. i- }1 S# 图标:img.ico% u. s" Q& c4 R5 t& A5 T8 |. }" E
pyinstaller -F -i img.ico del_mac_files.py
为了保证程序一直在后台运行,我们需要创建一个系统服务,让将可执行文件一直在后台执行。' N, D: h* G3 e- S j
instsrv.exe和srvany.exe这两个文件可以非常方便的创建系统服务。其中,instsrv.exe用于创建、删除服务;srvany.exe用于保障服务能正常启动。 " [+ Y: U& p/ n9 g' m* R) \ h( v- s