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
您的代碼中存在拼寫錯誤。仔細閱讀,看看你是否能夠發現你拼錯的名字。 –