import os
import fnmatch
for filename in os.listdir('.'):
if fnmatch.fnmatch(filename, '*.txt'): # 匹配模式为星号,表示任意的字符
os.remove(filename)
分类
删除同目录下面txt文件(利用os,fnmacth模块)
阅读(721) 评论(0)
import os
import fnmatch
for filename in os.listdir('.'):
if fnmatch.fnmatch(filename, '*.txt'): # 匹配模式为星号,表示任意的字符
os.remove(filename)