定时删除日志
import os,time,shutil
root=r'D:\pylx\20210622'
while True:
for item in os.listdir(root):
abs_path = os.path.join(root, item)
if time.time()-os.path.getctime(abs_path)>3600*24*3:
if os.path.isfile(abs_path):
os.remove(abs_path)
else:
shutil.rmtree(abs_path)
time.sleep(3600*24)
浙公网安备 33010602011771号