import os
import fnmatch
for filename in os.listdir(‘.‘):
if fnmatch.fnmatch(filename, ‘*.txt‘): # 匹配模式为星号,表示任意的字符
os.remove(filename)
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