Python Programming for the Absolute Beginner, 3rd Edition
In this chapter, you learned about files and exceptions. You learned how to read from text files. You saw how to read a single character or an entire file at once. You learned several different ways to read one full line at a time, probably the most common way to read a text file. You also learned how to write to text files—everything from a single character to a list of strings. Next, you learned how to save more complex data to files through pickling and how to manage a group of pickled objects in a single file using a shelf. Then, you saw how to handle exceptions raised during the execution of a program. You saw how to trap for specific exceptions and how to write code to work around them. Finally, you saw how to put files and exceptions together through the construction of a trivia game program that allows anyone with a text editor to create their very own trivia episodes.
Категории