Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python for file in dir

## Using scandir
import os

directory = r'C:Usersadmin'
for entry in os.scandir(directory):
    if (entry.path.endswith(".jpg")
            or entry.path.endswith(".png")) and entry.is_file():
        print(entry.path)
Comment

PREVIOUS NEXT
Code Example
Python :: discord.py unban command 
Python :: deleting all rows in pandas 
Python :: streamlit pip 
Python :: url decode python 
Python :: validation split python 
Python :: invert y axis python 
Python :: sort by index 2d array python 
Python :: generate a list of numbers upto n 
Python :: pandas drop unnamed columns 
Python :: django return httpresponse 
Python :: unix to date python 
Python :: convert numpy to torch 
Python :: python delete folder 
Python :: flask delete cookie stackoverflow 
Python :: track phone number location using python 
Python :: python reimport module 
Python :: python clean recycle bin 
Python :: clear terminal in python 
Python :: python current date 
Python :: pandas rename index 
Python :: python time.strptime milliseconds 
Python :: pandas plotly backend 
Python :: full form of ram 
Python :: matplotlib clear plot 
Python :: linux ubuntu install python 3.7 
Python :: python selenium run javascript 
Python :: python border 
Python :: what is self in programming 
Python :: get a list of column names pandas 
Python :: How to perform run-length encoding in Python? 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =