如何允许对strExtension使用.pdf和.html等格式。
如果我改为strExtension=“*”,脚本将不起作用。
如何使用这两种格式?pdf和html?你知道吗
# extension of files
strExtension = ".pdf"
# for each file in source directory
for file in os.listdir(sourceDir):
# if file ends with extension
if file.endswith(strExtension):
Tags:
这对我有用。谢谢你的快速帮助。非常感谢你们。。。你知道吗
str.endswith()
不支持通配符。但是,它支持元组,因此您可以执行以下操作:只需测试两种情况:
或者像乔恩·克莱门茨在下面评论的那样:
相关问题 更多 >
编程相关推荐