Computer Science · Ch 2 — File Handling in Python
Creating and Traversing a Text File
2.7
Creating and Traversing a Text File
Having learnt how to open and close a file, read and write data in a text file, and find or move the file object's position, let's now put these skills together to perform two basic operations on a text file: creating it (writing fresh data into it) and traversing it (reading through it from beginning to end). The textbook uses a file named practice.txt as the running example for these operations …