Answers for "how to read every line from txt file in python and store in list"

1

each line in a text file into a list in Python

with open('file1.txt','r') as f:
	listl=[]
	for line in f:
		strip_lines=line.strip()
		listli=strip_lines.split()
		print(listli)
		m=listl.append(listli)
	print(listl)
Posted by: Guest on December-03-2020
0

read a file line by line into a list

with open(fname) as f:
    content = f.read().splitlines()
Posted by: Guest on May-11-2021

Code answers related to "how to read every line from txt file in python and store in list"

Python Answers by Framework

Browse Popular Code Answers by Language