Powered by Blogger.

Social Icons

Featured Posts

List all files in a Directory in Python

Wednesday, February 22, 2023

import os

directory_path = "/path/to/directory"

#For windows
directory_path = "C:\\path\\to\\directory"

file_list = os.listdir(directory_path)

print("List of files in directory:")
for file_name in file_list:
    print(file_name)
 

Translate

Popular Posts