for filename in files: basename, extension = os.path.splitext(filename) code example
Example 1: python get file extension from path
import os.path
extension = os.path.splitext(filename)[1]
Example 2: os extension
>>> os.path.splitext('/a/b.c/d')
('/a/b.c/d', '')