DEV Community

Discussion on: Python – List Files in a Directory

Collapse
 
brandonwallace profile image
brandon_wallace

Nice article!

There is also the pathlib module.

from pathlib import Path

file_path = Path('.').cwd()

for file in file_path.iterdir():
    print(file)
Enter fullscreen mode Exit fullscreen mode
Collapse
 
srinivasr profile image
Srinivas Ramakrishna

Thanks for the feedback. I will add this techinque into the post