Answers for "python iterate through a folder"

17

how to iterate through files in a folder python

import os
directory = 'the/directory/you/want/to/use'

for filename in os.listdir(directory):
    if filename.endswith(".txt"):
      #do smth
      continue
    else:
    continue
Posted by: Guest on March-30-2020
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 "python iterate through a folder"

Python Answers by Framework

Browse Popular Code Answers by Language