Answers for "python read each line into a list"

3

python read each line into a list

with open(filename) as f:
    content = f.readlines()
# you may also want to remove whitespace characters like `\n` at the end of each line
content = [x.strip() for x in content]
Posted by: Guest on February-28-2020

Code answers related to "python read each line into a list"

Python Answers by Framework

Browse Popular Code Answers by Language