我用这个python程序得到了一个错误的"IOError:[Errno 0] Error":
from sys import argv
file = open("test.txt", "a+")
print file.tell() # not at the EOF place, why?
print file.read() # 1
file.write("Some stuff will be written to this file.") # 2
# there r some errs when both 1 & 2
print file.tell()
file.close()
Run Code Online (Sandbox Code Playgroud)
什么似乎是问题?以下这两种情况都可以:
from sys import argv
file = open("test.txt", "a+")
print file.tell() # not at the EOF place, why?
# print file.read() # 1
file.write("Some stuff will be written to this file.") # 2 …Run Code Online (Sandbox Code Playgroud) 我使用Windows 7.
myfile = open("matedata.txt", "a+")
print myfile.readline()
myfile.write("1")
myfile.close()
Run Code Online (Sandbox Code Playgroud)
这不起作用.
myfile.write("1")
IOError: [Errno 0] Error
Run Code Online (Sandbox Code Playgroud)