April 2024
Beginner
192 pages
3h 46m
English
Chapter 10
IN THIS CHAPTER
Working with text and binary files
Opening, closing, and reading the contents of a file
Looping through a file
Reading and copying a binary file
Pretty much everything stored in your computer, be it a document, program, movie, photograph, and more, is stored in a file. Most files are organized into folders (also called directories). You can browse through folders and files by using Finder (on a Mac) or File Explorer or Windows Explorer (in Windows).
Python offers many tools for creating, reading from, and writing to many different kinds of files. In this chapter, you learn the most important skills for using Python code to work with files.
There are basically two types of files: