當我使用python文檔(here)中的示例代碼時引發了AttributeError
。示例代碼如下:與os.scandir()引發AttributeError:__exit__
with os.scandir(path) as it:
for entry in it:
if not entry.name.startswith('.') and entry.is_file():
print(entry.name)
結果是AttributeError
:
D:\Programming>test.py
Traceback (most recent call last):
File "D:\Programming\test.py", line 3, in <module>
with os.scandir() as it:
AttributeError: __exit__
雖然,分配os.scandir()
到可變工作正常。 有人能告訴我我錯過了什麼嗎?
就是這樣。我仍然在3.5.2.3.6完美的作品,謝謝! –