Editing a file by substitution
tjreedy at udel.edu
Tue Aug 12 09:24:04 CEST 2008
> alex23 wrote:
>>>>> open('outfile','w').writelines(l.replace('Volume 940','Volume 950')
>>>>> for l in open('myfile','r'))
> Ahh yes, perhaps string function are simpler to use in this case.
> Thanks Alex!
If, if you have to change the file repeatedly, make it a template
(either % or the new .format variety) and substitute in the value you want.
More information about the Python-list