February 2024
Beginner
352 pages
8h 16m
English
If you did the Study Drills from the previous exercise, you should have seen all sorts of commands (methods/functions) you can give to files. Here’s the list of commands I want you to remember:
close—Closes the file. Like File->Save in a text editor or word processor.
read—Reads the contents of the file. You can assign the result to a variable.
readline—Reads just one line of a text file.
truncate—Empties the file. Watch out if you care about the file.
write('stuff')—Writes “stuff” to the file.
seek(0)—Move the read/write location to the beginning of the file.
One way to remember what each of these does is to think of a vinyl record, cassette tape, VHS tape, DVD, or CD player. In the early days of computers ...
Read now
Unlock full access