zaheer.ag...@gmail.com wrote:
Hi

How do i read  a file in Python and search a particular pattern
like I have a file char.txt  which has

Mango=sweet
Sky=blue

I want to get the strings sweet and blue,How to do this..?

for line in open('char.txt'):
  if line.find('sweet') != -1 or line.find('blue') != -1:
    print(line)

Read the section of the Lib Manual on string methods.

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to