删除同目录下面txt文件(利用os,fnmacth模块),osfnmacth

import os
import fnmatch
for filename in os.listdir(‘.’):
    if fnmatch.fnmatch(filename, ‘*.txt’): #
匹配模式为星号,表示任意的字符
        os.remove(filename)

删除同目录下面txt文件(利用os,fnmacth模块),osfnmacth

import os
import fnmatch
for filename in os.listdir(‘.’):
    if fnmatch.fnmatch(filename, ‘*.txt’): #
匹配模式为星号,表示任意的字符
        os.remove(filename)

http://www.bkjia.com/Pythonjc/1305409.htmlwww.bkjia.comtruehttp://www.bkjia.com/Pythonjc/1305409.htmlTechArticle删除同目录下面txt文件(利用os,fnmacth模块),osfnmacth
import os import fnmatch for filename in os.listdir(‘.’): if
fnmatch.fnmatch(filename, ‘*88bf必发娱乐,.txt’): # 匹配模式…