Reading a file
tjreedy at udel.edu
Sat Feb 14 18:45:44 CET 2009
zaheer.agadi at gmail.com wrote:
> How do i read a file in Python and search a particular pattern
> like I have a file char.txt which has
> 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:
Read the section of the Lib Manual on string methods.
More information about the Python-list