December 2009
Beginner to intermediate
360 pages
11h 12m
English
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 ...
Read now
Unlock full access