I got an err "IOError: [Errno 0] Error" with this python program:
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()
what seems to be the problem? These 2 cases below are ok:
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()
and:
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()
still, why
print file.tell() # not at the EOF place, why?
does not print the size of the file, is "a+" the append-mode? then the file pointer should point to EOF?
i'm using Windows 7 and Python 2.7.
tellreturns0just after opening the file, of course, why would you expect anything else?