[Tutor] newbie question--saving changes to a file

Ron Nixon nixonron@yahoo.com
Tue Mar 4 10:55:02 2003


--0-808239346-1046793263=:21820
Content-Type: text/plain; charset=us-ascii


How do I save the changes I make to a file say for example if I change old to new in a file and then want to save the new changes to another file?

import string

file = open('c:/file.txt')

s = file.read()

s.replace('old', 'new')

 

Please excuse the questions if it sounds to basic, but I have not be able to find an example of how to do this in the documentation--or perhaps I simply didn't see it.



---------------------------------
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, and more
--0-808239346-1046793263=:21820
Content-Type: text/html; charset=us-ascii

<P>How do I save the changes I make to a file say for example if I change old to new in a file and then want to save the new changes to another file?</P>
<P>import string</P>
<P>file = open('c:/file.txt')</P>
<P>s = file.read()</P>
<P>s.replace('old', 'new')</P>
<P>&nbsp;</P>
<P>Please excuse the questions if it sounds to basic, but I have not be able to find an example of how to do this in the documentation--or perhaps I simply didn't see it.</P><p><br><hr size=1>Do you Yahoo!?<br>
<a href="http://rd.yahoo.com/finance/mailtagline/*http://taxes.yahoo.com/">Yahoo! Tax Center</a> - forms, calculators, tips, and more
--0-808239346-1046793263=:21820--