Answers for "how to iterate through a folder in directory ptython"

1

python iterate directory

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
Posted by: Guest on February-22-2021

Code answers related to "how to iterate through a folder in directory ptython"

Python Answers by Framework

Browse Popular Code Answers by Language