import os dir = os.fsencode(filename='img') # here 'img' should be replaced with # desired directory lst = [] for items in os.listdir(dir): lst.append(items) print(lst)