0

Help needed on readline() in Python 3.0

Consider the following code: # Line by Line Printer fh = open('mbox.txt') fl = fh.readline(10) for line in fl: print(line) I intend to print the first 10 lines of the txt file, but the output is only the first line. What's the problem? Should I switch to readlines() ?

12/28/2016 8:32:16 AM

Ethan ZHOU

1 Answer

New Answer

0

with open("Filename",'r') as f: for i in range(10): print(f.readline())