This chapter covers
Probably the single most common thing you’ll want to do with files is open and read them.
In Python, you open and read a file using the built-in open function and various built-in reading operations. The following short Python program reads in one line from a text file named myfile:
file_object = open('myfile', 'r')line = file_object.readline()
open doesn’t read anything from the file; instead it returns an object called a file