Mega Code Archive

 
Categories / Python / File
 

Reading the entire file into a list

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 text_file.close()