打印所有以.txt为结尾的文件名称 import fnmatch import os for file in os.listdir('.'): if fnmatch.fnmatch(file, '*.txt'): print(file) 相关文章: