Replacing line in a text file
larry.bates at websafe.com
Mon Sep 25 16:20:08 CEST 2006
CSUIDL PROGRAMMEr wrote:
> 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
> I tried copying all file int list and then tried to manipulate that
> But the search is not working
> Any answer
Something simple like (not tested):
data='disable = yes'.join(data.split('disable = no',1))
More information about the Python-list