Reading a file

zaheer.agadi at gmail.com zaheer.agadi at gmail.com
Sun Feb 15 03:55:52 EST 2009


On Feb 15, 10:27 am, Steven D'Aprano <st... at pearwood.info> wrote:
> Philipp Pagel wrote:
> > zaheer.ag... at 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:
>
> The proper way to parse them would be with the ConfigParser module.
>
> The only negative with ConfigParser is that it requires a section label. In
> my experience it is quite common for INI files with only a single section
> to leave out the label.
>
> --
> Steven

Thanks to all of you,I used to ConfigParser worked fine.

-Zaheer



More information about the Python-list mailing list