#获取所有文件
def file():
for cur_dir, dirs, files in os.walk(r'/学习/接口自动化/BestTest/作业/logs'): # cur_dir(当前路径),dirs(目录),files(文件)中所有的
for file in files:
abs_path = os.path.join(cur_dir, file) # 获取绝对路径
if int(timestamp_to_str(abs_path.split("_")[1].split(".")[0], format='%Y-%m-%d')) < timestamp_to_str(format='%Y-%m-%d') - 60 * 60 * 24 * 3 or os.path.getsize(abs_path) == 0:
os.remove(abs_path)
else :
print("%s文件是3天内的,不需要删除"%file)
#三天前的时间
def timestamp_to_str(stringtime=None,format='%Y-%m-%d'):
#格式化时间转换为时间戳
if stringtime:
result=time.mktime(time.strptime(stringtime,format))
return int(result)
else:
result = time.time()
return int(result) file()
												

最新文章

  1. Maven详解
  2. phpmyadmin导入数据库大小限制修改
  3. Linux下因为系统编码问题造成乱码的解决办法
  4. java基础-继承
  5. mysql load data 乱码的问题
  6. 创建Fragment
  7. DataView usage combind with event and ViewModel From ERP-DEV
  8. Newtonsoft.Json序列化和反序列之javascriptConvert.SerializeObject,DeserializeObject,JsonWriter,JsonReader
  9. HDOJ 1326 Box of Bricks(简单题)
  10. Fix Elementary Boot Screen (plymouth) After Installing Nvidia Drivers
  11. 剑指offer--面试题3
  12. Hadoop平台基本组成
  13. python 文本比对
  14. 【java+selenium】网易云音乐刷累计听歌数
  15. 利用XML语法 SQL 列转行
  16. Reader 与 Guava MultiReader
  17. m4, autoconf
  18. OC Foundation框架—集合
  19. LeetCode - 566. Reshape the Matrix (C++) O(n)
  20. 对于yum中没有的源的解决办法-EPEL

热门文章

  1. Linux 中useradd命令的使用
  2. 使用numpy和PIL实现图像的手绘效果
  3. strongsan基本用法
  4. 【简说Python WEB】flask-mail电子邮件异步Asynchronous
  5. 小白学 Python 数据分析(20):pyecharts 概述
  6. 【Code Force】Round #589 (Div. 2) D、Complete Tripartite
  7. python plt 色卡
  8. [LeetCode] 935. Knight Dialer 骑士拨号器
  9. JAVA——桌球游戏(动画)
  10. 报错代码:svn-http status413&#39;requset entity too large