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..?

If your entire file consists of such key=value pairs you may want to properly 
parse them:

for lne in infile:
        line = line.rstrip()
        key, value = line.split('=')
        if key in ('Mango', 'Sky'):
                print value

Or something like that - details depend on what exactly your criteria for
picking the values are, of course.

cu
        Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl f. Genomorientierte Bioinformatik
Technische Universität München
http://mips.gsf.de/staff/pagel
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to