Answers for "iterate through a directory in python"

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
0

python loop through directory

import os

for filename in os.listdir(directory):
	print(filename)
Posted by: Guest on October-01-2021

Code answers related to "iterate through a directory in python"

Python Answers by Framework

Browse Popular Code Answers by Language