7READING AND WRITING FILES

image

To this point, we’ve read all input using the input function and written all output using the print function. These functions read from standard input (defaulting to the keyboard) and write to standard output (defaulting to the screen), respectively. While we can change these defaults using input and output redirection, sometimes a program needs more control over its files. For example, your word processor allows you to open whichever document file you like and save a file with whatever name you like, without you messing around with standard input and standard output.

In this chapter, we’ll learn how to write programs ...

Get Learn to Code by Solving Problems now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.