title | description | author | tags |
---|---|---|---|
Get File Extension |
Gets the extension of a file. |
axorax |
file,extension |
import os
def get_file_extension(filepath):
return os.path.splitext(filepath)[1]
# Usage:
get_file_extension('example.txt') # Returns: '.txt'