List the contents of a folder in Python

Os module provides the functionality to list the contents of folders.

import os
os.listdir(foldername)

Where 'foldername' is the name of the folder for which the contents need to be listed.

 

Leave a Reply

Your email address will not be published. Required fields are marked *