parsing text from a file

Vlastimil Brom vlastimil.brom at gmail.com
Thu Jan 29 17:08:11 EST 2009


2009/1/29 Wes James <comptekki at gmail.com>:
> If I read a windows registry file with a line like this:
>
...
>
> with this code:
>
> f=open('fwrules.reg2.txt')
>
> for s in f:
>  if s.find('LANDesk') <0:
>    print s,
>
>
> LANDesk is not found.
>
> how do I find LANDesk in a string like this.  is the "\\" messing things up?
...
>
> thx,
>
> -wj
>
Hi,
 if s.find('LANDesk') <0:
is True for a line which doesn't contain "LANDesk"; if you want the
opposite, try
 if s.find('LANDesk') >-1:
hth
  vbr



More information about the Python-list mailing list