Is there a function to extract the extension from a filename?
You can find some great stuff in pathlib module (available in python 3.x).
import pathlib x = pathlib.PurePosixPath("C:\\Path\\To\\File\\myfile.txt").suffix print(x) # Output '.txt'