readln() until EOF

K

korean_dave

a = open("Thefile.txt","r")

while ?????:
result = a.readln()

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

I don't want to break the loop if there is a blank line, because there
will be.

Ex. of a file:

map1
result1

map2
result 2

map3
result3
comments

thanks...
 
B

Bruno Desthuilliers

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()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top