我是python新手,我对以下语法有问题
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
在这个语法上,我得到
^{pr2}$我从在线教程中得到它,我正在使用python3。你知道什么会导致这种错误信息吗?在
这是个打字错误。您已经打开了
text_file
,但是行想从关闭的
^{pr2}$test_file
读取。将行改为:相关问题 更多 >
编程相关推荐