How to List Files in a Directory with Python

713 views Feb 21, 2023
codefather.tech

This quick tutorial shows how to use the Python os module to list files in a directory. You will use a for loop to go through the output of the os.listdir() method and then print the full path of each file inside the loop. We will also see how to use the string endswith() method to filter files based on their extension. Enjoy this tutorial! Claudio #Shorts