gpt4 book ai didi

python - 属性错误 : 'module' object has no attribute 'scandir'

转载 作者:太空宇宙 更新时间:2023-11-04 05:34:55 27 4
gpt4 key购买 nike

我不知道为什么会这样。这是函数:

def scanWallDir(basedir, scansubdirs=True):
wallsOut = []
for entry in os.scandir(basedir):
if entry.is_file():
print(("file " + entry.name))
elif entry.is_dir():
print(("dir " + entry.name))

错误:

/usr/bin/python2.7 /home/aidan/Code/ulwscs/ulwscs.py
Traceback (most recent call last):
File "/home/aidan/Code/ulwscs/ulwscs.py", line 38, in <module>
scanWallDir("/media/Crossover/Wallpapers")
File "/home/aidan/Code/ulwscs/ulwscs.py", line 11, in scanWallDir
for entry in os.scandir(basedir):
AttributeError: 'module' object has no attribute 'scandir'

Process finished with exit code 1

有人知道会发生什么吗?

最佳答案

Pycharm 重置了我使用的 Python 版本。我是个白痴。

关于python - 属性错误 : 'module' object has no attribute 'scandir' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35926032/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com