编程语言
首页 > 编程语言> > python 模块fnmatch

python 模块fnmatch

作者:互联网

fnmatch 模块下的 fnmatch() 函数要求两个参数:文件名,以及文件名模式,返回的是布尔值。文件名模式中,支持 * 符号匹配任意字符。结合列表生成式,我们就可以快速过滤出符合条件的文件名了。

from fnmatch import fnmatch
path='...'
files = os.listdir(path)
deps = [i for i in files if fnmatch(i, "*共同内容.xlsx")]
print(deps)

标签:files,模块,文件名,python,deps,fnmatch,path
来源: https://blog.csdn.net/u011389452/article/details/112062682