2
我是新来的蟒蛇,我有问题的语法如下为什么我收到unsupportedoperation:读
test_file = open("test.txt", "wb")
test_file.write(bytes("Write me to the file\n", 'UTF-8'))
test_file.close()
text_file = open("test.txt","r+")
text_in_file = test_file.read() # this is where the error emerges
# more code goes here
在此语法中,我得到
io.UnsupportedOperation: read
我得到了它在网上形成教程和我正在使用python 3.你知道什么可能导致这样的错误信息?
再次,这对于使用外部文件来说可能是基本的但非常重要 – Lucas
您的代码中存在拼写错误。仔细阅读,看看你是否能够发现你拼错的名字。 –