[Tutor] searching in files
Kent Johnson
kent_johnson at skillsoft.com
Wed Aug 11 16:55:54 CEST 2004
You can iterate over lines in a file without reading in the whole file at
once, using
for line in aFile:
>>> f=open('index.html')
>>> for line in f:
... if '<h3>' in line:
... print line
...
<h3><i>Python Rocks!</i></h3>
<h3>Blogging</h3>
<h3>About me</h3>
Kent
At 07:46 AM 8/11/2004 -0700, Ali Polatel wrote:
>Yes I know the method readlines but the file is enorm large and it can
>make the computer slow if I make the programme read all of it into a
>sentence...
>Any other advices?
>Regards
>
>
>Do you Yahoo!?
>Yahoo! Mail is new and improved -
><http://us.rd.yahoo.com/mail_us/taglines/new/*http://promotions.yahoo.com/new_mail>Check
>it out!
>_______________________________________________
>Tutor maillist - Tutor at python.org
>http://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list