Looping through the file, line by line. : Text File Read « File « Python






Looping through the file, line by line.


print "\nLooping through the file, line by line."
text_file = open("read_it.txt", "r")
for line in text_file:
    print line
text_file.close()

           
       








Related examples in the same category

1.Text files: iterating over the lines in the file
2.Demonstrates reading from a text file
3.Reading characters from the file.
4.Reading the entire file at once
5.Reading characters from a line.
6.Reading one line at a time.
7.Reading the entire file into a list.