[Tutor] Read and write from file
python at kapitalisten.no
Wed Aug 25 20:29:25 CEST 2004
I am trying to read and write from a file, but I cannot get it to do so.
The file has the following lines:
I open the file with
fil = open('d:\\test.txt','rw')
(I have tried, r, w, w+, r+, a and a+ as well.)
and so forth.
If I try
it skips to 4. Why? And why does not the file contain the word test? I
ahve tried both fil.close and fil.flush without any luck.
What I really want to do is to read the first line, 1, then replace that
with something else, or remove it. Then read 2, and remove it, then read 3
and change it and so forth. How can I read, write and modify at the same
time? So far I have only been able to either read or write, but not both.
Thanks in advance....
This email has been scanned for viruses & spam by Decna as - www.decna.no
Denne E-post er sjekket for virus & spam av Decna as - www.decna.no
More information about the Tutor