Answers for "read file line into a list without newline"

3

python read file without newline

# converts read file into a list without newlines
temp = file.read().splitlines()
Posted by: Guest on April-15-2020
1

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
Posted by: Guest on April-03-2021

Code answers related to "read file line into a list without newline"

Python Answers by Framework

Browse Popular Code Answers by Language