匹配当前目录指定后缀的文件名

打印所有以.txt为结尾的文件名称

import fnmatch
import os

for file in os.listdir('.'):
    if fnmatch.fnmatch(file, '*.txt'):
        print(file)

原文地址:https://www.cnblogs.com/sea-stream/p/10002552.html