O'Reilly logo

Python: Visual QuickStart Guide, Second Edition by Toby Donaldson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 8. Input and Output

To be useful, a program needs to communicate with the world around it. It needs to interact with the user, or read and write files, or access Web pages, and so on. In general, we refer to this as input and output, or I/O for short.

We’ve already seen basic console I/O, which involves printing messages and using the input function to read strings from the user. Now we’ll see some string formatting that lets you make fancy output strings for console I/O and anywhere you need a formatted string.

Then we’ll turn to file I/O, which is all about reading and writing files. Python provides a lot of support for basic file I/O, making it as easy as possible for programmers. In particular, we’ll see how to use text files, binary ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required