Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个文件扩展名,我是这样得到的:
fileName, fileExtension = os.path.splitext(abspath)
现在我需要我的文件扩展名变成一个模式,比如'*.fileExtension',包括引号字符。我应该fnmatch像这样使用它:
fnmatch
if fnmatch.fnmatch(name, pattern)
任何想法?
使用字符串连接:
pattern = '*' + fileExtension
或使用字符串格式:
pattern = '*{}'.format(fileExtension)
或者
pattern = '*%s' % fileExtension