我得到了一个错误“IOError:[Errno 0] Error”这个python程序:
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()
似乎是什么问题?以下这两种情况都可以:
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()
和:
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()
还是,为什么
print file.tell() # not at the EOF place, why?
不打印文件的大小,“a+”是附加模式吗?那么文件指针应该指向EOF吗?
我正在使用 Windows 7 和 Python 2.7。