Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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
Comment

python loop through directory

import os

for filename in os.listdir(directory):
	print(filename)
Comment

python loop 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
Comment

loop through files in a directory python

import os

for filename in os.listdir("/path/to/dir/"):
    if filename.endswith(".asm") or filename.endswith(".py"): 
         # print(os.path.join(directory, filename))
        continue
    else:
        continue
Comment

PREVIOUS NEXT
Code Example
Python :: how to receive password using tkinter entry 
Python :: load custom font pygame 
Python :: install python3.7 ubuntu 20.04 
Python :: créer des variable dynamiques python 
Python :: how to install wxpython 
Python :: pandas drop empty columns 
Python :: html to json python 
Python :: Install requests-html library in python 
Python :: autoclicker in python 
Python :: how to calculate running time in python 
Python :: tkinter load image 
Python :: python split range equally 
Python :: np float to int 
Python :: discord.py commands not working 
Python :: between date pandas 
Python :: how will you print space and stay on the same line in python 
Python :: python read url 
Python :: python pendas shut off FutureWarning 
Python :: python tts 
Python :: how to convert a list into a dataframe in python 
Python :: spress warnings selenium python 
Python :: how to make it so the pygame window will close 
Python :: python system arguments 
Python :: apply format to pandas datetime column 
Python :: changing dtype of multiple columns to_datetime 
Python :: python querystring parse 
Python :: python sort list of strings numerically 
Python :: brownie to wei 
Python :: fix ImportError: No module named PIL 
Python :: module pygame has no member 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =