readln() until EOF

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Thu Jul 24 21:25:59 CEST 2008


korean_dave a écrit :
> a = open("Thefile.txt","r")
> 
> while ?????:
>   result = a.readln()

I assume you meant "a.readline()" ? Anyway...

> what do i put in ???? if i want to keep reading line by line until i
> reach the end of the file?

a = open("path/to/file.ext")
for line in a:
    do_something_with(line)
a.close()




More information about the Python-list mailing list