[newbie] Read file, and append?
Gilles Ganault
nospam at nospam.com
Wed Dec 26 17:04:33 EST 2007
On Tue, 25 Dec 2007 13:27:09 -0800, Dennis Lee Bieber
<wlfraed at ix.netcom.com> wrote:
>Ignoring the question of the proper I/O mode, I believe the I/O
>system MAY require one to perform a seek() when switching from read to
>write and vice versa...
I thought about this, but I don't understand why I would need to do
this:
myfile=open('test.txt','r+')
content = myfile.read()
myfile.seek()
myfile.write('added this')
myfile.close
Is there really no way to read from a file and append data to it while
keeping the file open?
Also, I noticed a problem with the code given by Garry: When opening a
file in binary mode, the EOF character is 0A, while Windows apps
expect 0D0A. VisualBasic was not happy :-)
More information about the Python-list
mailing list