Python批量删除特定文件

来源:互联网 发布:淘宝审核不通过怎么办 编辑:程序博客网 时间:2024/06/06 11:37
#!/usr/bin/env python# -*- coding: utf-8 -*-import fnmatchimport osfor file in os.listdir("."):         # 逐行读取目录文件,(.为当前目录,其他可以任意指定文件夹目录,比如abc)    if fnmatch.fnmatch(file, "out_ft*.txt"):   # 判断输入文件是否符合out_ft*.txt标准,如果符合则打印且删除        print file       os.remove(file)
0 0
原创粉丝点击