复制代码

为懒人提供无限可能,生命不息,code不止

人类感性的情绪,让我们知难行难
我思故我在
日拱一卒,功不唐捐
  • 首页
  • 前端
  • 后台
  • 数据库
  • 运维
  • 资源下载
  • 实用工具
  • 接口文档工具
  • 登录
  • 注册

centOS

【原创】python3 删除文件名中带特殊字符的文件

作者: whooyun发表于: 2022-08-04 16:37

删除带20字符的文件

python代码

import os
path = r'/home/zbwdev/nacos/logs'
files = os.listdir(path)
for i, f in enumerate(files):
    if f.find("20") >= 0:
        print(i)
        result = os.path.join(path, f)
        print(result)
        os.remove(result)
crontab代码

1 0 * * * python3 /opt/auto_exe_script/auto_del_log.py