4 Handy Ways to List Files in a Directory With Python

Claudio Sabato
6 min readDec 14, 2022

Do you want to find out how to list files in a directory using Python? In this article, you will see how to do it in 4 different ways so you can choose the one you prefer.

In all the examples we will list files in a directory with the following structure. We will call the directory test_dir:

├── data
│ └── tech.txt
└── report.txt

1 directory, 2…
Claudio Sabato

I’m a Software Engineer and Programming Coach. I want to help you in your journey to become a Super Developer!