how to modify row content of file in python?

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Tue Oct 27 05:45:44 EDT 2009


En Tue, 27 Oct 2009 05:50:47 -0300, Lutz Horn <lutz.horn at fastmail.fm>  
escribió:
> * holmes86 [Tue, 27 Oct 2009 00:55:36 -0700]:

>> Is there function of modify row content in python? just like 'sed' in
>> shell,thanks
>
> Sed doesn't actually modify the contents of a file. In normal operation
> mode it reads from STDIN and writes to STDOUT. Some versions of sed
> provide the -i option to
>
>   edit files in place (makes backup if extension supplied)
>
> You could program a similar behaviour in Python using the re module.

There is the fileinput module:
http://docs.python.org/library/fileinput.html

-- 
Gabriel Genellina




More information about the Python-list mailing list