Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python check file extension

# Checking for single extension (.txt) of file
if file.endswith(".txt"):
  # do something
  
# Checking multiple extensions (.txt, .pdf, .mp3, ...)
if file.endswith((".txt", ".pdf", ".mp3")):
  # do something
Comment

PREVIOUS NEXT
Code Example
Python :: how to take array input in python in single line 
Python :: dataframe memory usage 
Python :: python read xlsb pandas 
Python :: find element by title selenium python 
Python :: get python directiory 
Python :: python log with timestamp 
Python :: python reload class 
Python :: divide by zero error python exception handling 
Python :: export file csv python 
Python :: python easter eggs 
Python :: selenium driver wait python 
Python :: change default python version mac 
Python :: turn list to string with commas python 
Python :: ERROR: Failed building wheel for Pillow 
Python :: python how to generate random number in a range 
Python :: make string numeric pandas 
Python :: how to check if left mousebuttondown in pygame 
Python :: search code ascii python 
Python :: shuffle dataframe python 
Python :: python how to flatten a list 
Python :: convert pandas datetime to day, weekday, month 
Python :: print today time python 
Python :: convert pandas dataframe to spark dataframe 
Python :: argparse 
Python :: tkinter give button 2 commands 
Python :: Convert a Video in python to individual Frames 
Python :: python check if there is internet 
Python :: python time calculation 
Python :: comment dériver une classe python 
Python :: Exception: ROM is missing for space_invaders, see https://github.com/openai/atari-py#roms for instructions site:stackoverflow.com 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =