时间:2021-07-01 10:21:17 帮助过:59人阅读
这里给定一个搜索路径,需要在此目录中找出所有符合匹配模式的文件
import glob, os def all_files(pattern, search_path, pathsep = os.pathsep): for path in search_path.split(pathsep): for match in glob.glob(os.path.join(path, pattern)): yield match print(type(all_files('*.s', 'd:\\pm\\pm'))) print(all_files('*.s', 'd:\\pm\\pm').__next__()) for match in all_files('*.s', 'd:\\pm\\pm'): print(match)
希望本文所述对大家的Python3程序设计有所帮助。