Answers for "python iterate through folders"

1

python iterate directory

import os

directory = r'C:\Users\admin'
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 iterate through files in directory

import os

for filename in os.listdir(directory):
    if filename.endswith(".asm") or filename.endswith(".py"): 
         # print(os.path.join(directory, filename))
        continue
    else:
        continue
Posted by: Guest on October-26-2020

Code answers related to "python iterate through folders"

Python Answers by Framework

Browse Popular Code Answers by Language