Mir Khashkhash Mir Khashkhash - 1 year ago 77
Python Question

How to read the entire file into a list in python?

I want to read an entire file into a python list any one knows how to?

Max Max
Answer Source
print "\nReading the entire file into a list."
text_file = open("read_it.txt", "r")
lines = text_file.readlines()
print lines
print len(lines)
for line in lines:
    print line
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download