Answers for "python how to check the file extension"

3

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
Posted by: Guest on November-04-2020
1

simple way of finding file extension python programming

file = input("Which file did you opend last time user:- ")
extenction = file.split(".")
print("humm so last time you opened file extenction was .",extenction[1])
Posted by: Guest on July-26-2021

Code answers related to "python how to check the file extension"

Python Answers by Framework

Browse Popular Code Answers by Language