An AttributeError
được nâng lên khi tôi sử dụng mã ví dụ từ tài liệu của python (here). Đoạn mã ví dụ như sau:với os.scandir() tăng AttributeError: __exit__
with os.scandir(path) as it:
for entry in it:
if not entry.name.startswith('.') and entry.is_file():
print(entry.name)
Kết quả là một 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__
Mặc dù, gán os.scandir()
cho một biến hoạt động tốt. Ai đó có thể cho tôi biết tôi đang thiếu gì không?
Vậy đó. Tôi vẫn còn trên 3.5.2.3.6 hoạt động hoàn hảo, cảm ơn! –