Python Programming with the Java™ Class Libraries: A Tutorial for Building Web and Enterprise Applications with Jython
by Richard Hightower
Summary
Python allows you to read and write to files. The Python file object, which is built into the language, supports the following methods:
read()— read in data from a file
readline()— read a line of data from a file
readlines()— read all the lines in the file and return the lines as a list of strings
write()— write data to a file
writelines()— write a sequence of lines to a file
seek()— move to a certain point in a file
tell()— determine the current location in the file
Python makes working with files straightforward. In addition, its pickle and cPickle modules allow the persisting of objects to a file or string and make for speedy development of persisted class data.
In this chapter, we expanded on the address book example from Chapter 4. We ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access