递归删除Mac os 系统下专属文件
import os
def read_dirname(path):
files = os.listdir(path)
for file in files:
if os.path.isdir(f'{path}/{file}'):
read_dirname(f'{path}/{file}')
elif file[0] == '.' and os.path.exists(f'{path}/{file[2:]}'):
# os.popen(f'rm -f "{path}/{file}"') 存在特殊文件名称无法删除情况
os.remove(f'{path}/{file}')
print(f'{path}/{file} is Done')
elif file == '.DS_Store':
os.remove(f'{path}/{file}')
print(f'{path}/{file} is Done')
if __name__ == '__main__':
read_dirname('/data/mobile_disk/Mac支持')