[Tutor] file open (take 2)
Dave S
pythontut at pusspaws.net
Wed Sep 27 22:59:36 CEST 2006
Hi,
I am trying to read in an ascii text file, do some alterations and write it
back.
file = open(self.config.get('pdf','cert') + '/cert.pdf' , 'r+')
lines = file.readlines()
... process lines ...
file.writelines(lines)
file.close()
works but ends up appending a second modified copy to the original ... as per
the python ref.
Am I right in thinking that the only way is to open with a 'r', close them
open with a 'w' ?
Cheers
Dave
More information about the Tutor
mailing list