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 x/ ^6 |2 X! V1 I) Y
# 安装 pyinstaller 0 @1 T. I, ]6 ?5 {' d+ Y! opip3 install pyinstaller % U- D4 @7 _3 Y1 u5 }9 I$ J
# 把 py 文件打包成 exe 可执行文件+ X4 U3 [2 W. v7 d4 c/ I. }1 g* v
# 图标:img.ico " @3 Y4 W6 N/ e) c) ]( Apyinstaller -F -i img.ico del_mac_files.py
为了保证程序一直在后台运行,我们需要创建一个系统服务,让将可执行文件一直在后台执行。, G; _5 i2 y6 M6 g+ j" y. `$ d5 g
instsrv.exe和srvany.exe这两个文件可以非常方便的创建系统服务。其中,instsrv.exe用于创建、删除服务;srvany.exe用于保障服务能正常启动。 $ M( J4 n2 N& a7 @