import os
directory = r'C:Usersadmin'
for filename in os.listdir(directory):
if filename.endswith(".jpg") or filename.endswith(".png"):
print(os.path.join(directory, filename))
else:
continue
import os
for filename in os.listdir(directory):
print(filename)
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)