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可执行文件。 + Y, a4 @$ E9 e
# 安装 pyinstaller 0 m5 u; E2 `* M" Bpip3 install pyinstaller # B' Z3 j0 k4 W$ H
# 把 py 文件打包成 exe 可执行文件" G0 S4 h. U3 w" H0 y" @8 W
# 图标:img.ico* m4 V4 P. R; H$ Y1 ]. d7 M3 D
pyinstaller -F -i img.ico del_mac_files.py
为了保证程序一直在后台运行,我们需要创建一个系统服务,让将可执行文件一直在后台执行。 ( i h+ H7 s d' w# Q6 Y; h3 ? instsrv.exe和srvany.exe这两个文件可以非常方便的创建系统服务。其中,instsrv.exe用于创建、删除服务;srvany.exe用于保障服务能正常启动。 * }4 s7 i8 W4 @. x* k0 A