Python Get File Extension from Filename Example
This tutorial is focused on python get file extension from filename. you can understand a concept of python get file extension from path. letâ€™s discuss about python get filename extension from path. it's simple example of how to get file extension in python. You just need to some step to done how to get file extension from path python.
In this example, I will give you a simple example of getting the file extension from file path. so let's see a simple example with output.
You can use these examples with python3 (Python 3) version.
import os fileName, fileExtension = os.path.splitext('/images/demo.png') print("File Name: ", fileName) print("File Extension: ", fileExtension)
File Name: /images/demo File Extension: .png
I hope it can help you...
We are Recommending you
- Python Get First Date of Next Month Example
- Python Create Zip Archive from Directory Example
- Python List All Dates Between Two Dates Example
- How to Compare Two Dates in Python?
- How to Check if Today is Sunday or not in Python?
- How to Add Minutes to DateTime in Python?
- Python POST Request with Parameters Example
- How to Get Tomorrow Date in Python?
- How to Get Current Minute in Python?
- How to Get Current Hour in Python?
- How to Get Current Year in Python?