Editing a file by substitution
Terry Reedy
tjreedy at udel.edu
Tue Aug 12 03:24:04 EDT 2008
Brad wrote:
> 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
mailing list