What do you mean 'recognize'? The file name is a string, you just need to match the end of that string.
You can use os.path.splitext(filename.ext) to get ('filename', '.ext'), or just test 'filename.ext'.endswith('.ext'), or 'filename.ext'[-4:] == '.ext'. Throw a 'FiLeNaMe.eXt'.lower() in there to catch weird case situations.
You can use os.path.splitext(filename.ext) to get ('filename', '.ext'), or just test 'filename.ext'.endswith('.ext'), or 'filename.ext'[-4:] == '.ext'. Throw a 'FiLeNaMe.eXt'.lower() in there to catch weird case situations.