在匹配某文件夹下,查找以某个后缀结尾的文件时,可以使用glob模块 import glob import os path = "." glob.glob(os.path.join(path, "*.rar")) 这样就可以找到rar文件了~