how to know the end of a file(use readline)

Alex Martelli aleaxit at yahoo.com
Tue Jul 31 09:20:30 EDT 2001


"sdf" <wqh-2 at 263.net> wrote in message
news:mailman.996580197.11033.python-list at python.org...
> I use readline to process the whole ,but
> I do not know how to control it,when it
> is the end of the file

f.readline() returns an empty string, '',
when f is at end of line, and in no other
case (when reading an empty line, it
returns '\n': just a special useful case
of the fact that readline does NOT remove
the trailing '\n' from the line it reads).


Alex






More information about the Python-list mailing list