匹配当前目录指定后缀的文件名 打印所有以.txt为结尾的文件名称 import fnmatch import os for file in os.listdir('.'): if fnmatch.fnmatch(file, '*.txt'): print(file)