Replacing line in a text file

Eric eric.talevich at gmail.com
Fri Sep 22 22:26:12 EDT 2006


CSUIDL PROGRAMMEr wrote:
> Folks
> I am trying to read a file
> This file has a line containing string  'disable = yes'
>
> I want to change this line to 'disable = no'
>
> The concern here is that , i plan to take into account the white spaces
> also.
>
> I tried copying all file int list and then tried to manipulate that
> list
>
> But the search is not working
>
> Any answer
>
> thanks

Is this a configuration file? Depending on what exactly is in the file,
you may want to either import it directly or parse it -- especially if
"disable = yes" appears more than once in the file.

Could you post an example of the file for us?




More information about the Python-list mailing list