Changing a line in a text file

Miki Tebeka miki.tebeka at zoran.com
Mon Apr 25 07:09:53 EDT 2005


Hello kah,

> How do I change a line in a file??
> 
> For example I have the follwing text in my file:
> 
> line1
> line2
> line3
> line4
> 
> How do I replace 'line2' with 'newline'. Since the write operation in
> python will  overwrite everything.
See http://docs.python.org/lib/module-fileinput.html (inplace=1 is what you
want).

Bye.
--
------------------------------------------------------------------------
Miki Tebeka <miki.tebeka at zoran.com>
http://tebeka.bizhat.com
The only difference between children and adults is the price of the toys
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 193 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20050425/33aa3dd8/attachment.sig>


More information about the Python-list mailing list