Working with Files
Read, write, and manage files and directories using Python.

Join the AI Workshop to learn more about AI and how it can be applied to web development. Next cohort February 1st, 2026

The AI-first Web Development BOOTCAMP cohort starts February 24th, 2026. 10 weeks of intensive training and hands-on projects.


Working with files is one of Python’s most practical capabilities. Python makes it easy to read configuration files, process data, generate reports, and automate any task that involves file manipulation.

In this unit, you’ll learn how to work with files in Python. We’ll cover opening and reading files, writing and appending data, working with different file formats, managing directories, and handling file paths across different operating systems.

These file handling skills are essential for data processing, automation scripts, configuration management, and countless other real-world Python applications.

Lessons in this unit:

0: ▶︎ Introduction
1: Check if file or directory exists
2: Create an empty file
3: Create a directory
4: Read the content of a file
5: Write to a file
6: List files in a directory
7: Get the details of a file
8: The with statement