问题
你想使用Unix Shell中常用的通配符(比如*.py,Date[0-9]*.csv
等)去匹配文本支付串
解决方案
fnamtch模块提供了两个模块函数–fnamtch()和fnmatchcase(),可以用来实现这样的匹配。
from fnmatch import fnmatch,fnmatchcase
print(fnmatch('foo.txt','*.txt')) # ->True
print(fnmatch('foo.txt','?oo.txt'))# ->True