QuickSnip LogoA light blue logo with a thunderbolt in bracketsQuickSnip

Get File Extension

Gets the extension of a file.

  • file
  • extension

Code

import os

def get_file_extension(filepath):
    return os.path.splitext(filepath)[1]

Usage

get_file_extension('example.txt') # Returns: '.txt'