import os file_details = os.path.splitext('/path/file.ext') print(file_details) print(file_details[1])