[英]Why is the glob method finding different files in Python?
可能是两次运行配置中指定的工作目录不同,或者每次运行时unsorted glob看起来都不一样。
无论如何,具体说明您想要 glob 的路径(并对 glob 进行排序)应该可以解决问题:
from pathlib import Path
path = Path(__file__).parent # The directory that this file is in
for file in sorted(path.glob('*')):
print(file)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.