一个目录下有文件,文件夹,文件夹里又有文件.文件夹....用python脚本,实现,递归删除一个目录下的所有文件: 目录结构如下: 其中我们要删除所有文件 代码实现如下: import os CUR_PATH = r'C:\Users\shenping\PycharmProjects\Shenping_TEST\day_5\Testfolder' def del_file(path): ls = os.listdir(path) for i in ls: c_path = os.path.joi…
import os import time import datetime def should_remove(path, pattern, days): if not path.endswith(pattern): return False mtime = os.path.getmtime(path) now = time.time() result = now - mtime > days * 24 * 3600 print "\n>>>>>>>…