python 删除大于超过一定时间文件
import os
from datetime import datetime, timedelta
path = "."
if __name__ == '__main__':
for root, firs, files in os.walk(path):
for file in files:
if datetime.fromtimestamp(os.path.getctime(file)) < datetime.now() - timedelta(seconds=300):
pass
# os.remove(path + file)
else:
print(" cant not remove name : %s" % file)
本文来自博客园,作者:vx_guanchaoguo0,转载请注明原文链接:https://www.cnblogs.com/guanchaoguo/p/17143331.html