简单的问题陈述。我想异步读取文件。我的问题是当我尝试使用 aiofiles.open 读取文件时,它只是出现了神秘的消息错误
AttributeError: __enter_
问题的症结可以用下面的例子来证明
with open("/tmp/test/abc_20211105.txt","w") as f:
f.write("this is a sample!")
with aiofiles.open('/tmp/test/abc_20211105.txt','r') as f: # This is where the error occurs
f.read()
该文件已创建,但我无法使用 aiofiles 读取相同的文件。
我试过指定编码等,但没有任何帮助。
这个错误是什么意思?