Lesson 1 of 4: 1. Learning Outcomes
At the end of this course, you will be able to
- Explain the concepts of persistence
- Implement programs that persist data and handle exceptions
2. Concept of Persistence (40 Mins)
Lesson 2 of 4: 2.1 What is Persistence
Persistent storage is any data storage device that retains data after power to that device is shut off. Some of the common examples are hard disk drives, tapes, or DVD. Persistent storage systems can be in the form of file, block or object storage.
https://youtu.be/uvyerY_dHJk
Lesson 3 of 4: 2.2 File Input and Output
How do you use python to read from a file and write into a file?
https://youtu.be/Uh2ebFW8OYM
In summary, to read content from a file (assuming it is a text file),
- use open(filename,'r') to initialize the file object
- use for-loop to iterate through the content. (or while loop with read())
- close() the file reader when we are done
To write the content to a file (similiarly, let's assume it is a text file),
- use open(filename,'w') to initialize the file object
- use write() to write content to file