import os
import fnmatch
for filename in os.listdir('.'):
if fnmatch.fnmatch(filename, '*.txt'): # 匹配模式为星号,表示任意的字符
os.remove(filename)
转载于:https://www.cnblogs.com/o8o8o8/p/8456211.html
import os
import fnmatch
for filename in os.listdir('.'):
if fnmatch.fnmatch(filename, '*.txt'): # 匹配模式为星号,表示任意的字符
os.remove(filename)
转载于:https://www.cnblogs.com/o8o8o8/p/8456211.html