Is there a function to extract the extension from a filename?
Thanks all! That's what I needed!
Is there a function to extract the extension from a filename?
Thanks all! That's what I needed!
Yes. use os.path.splitext
.
>>> import os
>>> basename, extension = os.path.splitext('/path/to/somefile.ext')
>>> basename
'/path/to/somefile'
>>> extension
'.ext'