Reading the entire file at once : Text File Read « File « Python






Reading the entire file at once



print "\nReading the entire file at once."
text_file = open("read_it.txt", "r")
whole_thing = text_file.read()
print whole_thing
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 characters from a line.
5.Reading one line at a time.
6.Reading the entire file into a list.
7.Looping through the file, line by line.