AI Workshop: learn to build apps with AI →
Working with Files
Read, write, and manage files and directories using Python.

Join the AI Workshop and learn to build real-world apps with AI. A hands-on, practical program to level up your skills.


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