So far, your programs have only worked with data while they are running. When the program ends, everything in memory disappears.
Files let your programs:
- Save data so it’s still there next time you run the program.
- Load existing data instead of typing it every time.
- Exchange information with other programs (for example, reading a
.csvfile exported from Excel). - Work with real-world information: logs, configuration files, documents, etc.
Python makes working with files relatively simple. In this chapter you’ll learn the basics needed for simple text-based programs.