<分区>
我使用的是 Windows 7。
myfile = open("matedata.txt", "a+")
print myfile.readline()
myfile.write("1")
myfile.close()
这行不通。
myfile.write("1")
IOError: [Errno 0] Error
<分区>
我使用的是 Windows 7。
myfile = open("matedata.txt", "a+")
print myfile.readline()
myfile.write("1")
myfile.close()
这行不通。
myfile.write("1")
IOError: [Errno 0] Error
最佳答案
当你用 python 打开一个文件时,你需要指定你想要的访问类型(读取、写入或追加):
'+' 表示如果不存在则更新/创建新的。
您收到 IOError 是因为您打开文件并尝试使用相同的 FD(文件鉴别器)进行读取和写入
关于python - IO错误 : [Errno 0] Error in Python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19881890/