Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python read text file next line

filepath = 'Iliad.txt'
with open(filepath) as fp:
   line = fp.readline()
   cnt = 1
   while line:
       print("Line {}: {}".format(cnt, line.strip()))
       line = fp.readline()
       cnt += 1
Source by stackabuse.com #
 
PREVIOUS NEXT
Tagged: #python #read #text #file #line
ADD COMMENT
Topic
Name
3+8 =