find string in file

Roman Dodin roman.dodin at softjoys.com
Fri Mar 14 10:02:48 EDT 2008



On 14 mar, 14:25, fminerv... at gmail.com wrote:
>> Hi friends !!
>>
>> I'm neophite about python, my target is to create a programa that
>> find  a specific string in text file.
>> How can do it?
>>
>> Thanks
>> fel
>>     
>
>
>   
One more way to do this

f = codecs.open("log.txt", 'r', "utf_16_le")
lines = f.readlines()
for line in lines:
   if(line.find("my string to find")!=-1):
      print line



More information about the Python-list mailing list