On this page
ntpath.splitext
Prev: ntpath.splitdrive | Up: ntpath | Next: ntpath.splitroot
Rel: ntpath.abspath, ntpath.basename, ntpath.commonpath, ntpath.commonprefix
Ref: docs.python.org — ntpath.splitext
Tags: #public #python3 #stdlib #ntpath
Import
import ntpath
from ntpath import splitext
Signature & Overview
ntpath.splitext(p)
Split the extension from a pathname.
Usage
import ntpath
assert ntpath.splitext(r'C:\a\file.tar.gz') == (r'C:\a\file.tar', '.gz')
Gotchas
- Splits only the LAST extension and keeps leading dot-files intact (
splitext('.env') == ('.env', '')).
REPL Inspect
from ntpath import splitext
help(splitext)
Linked from
Related notes
- tuts/python3/stdlib_module/ntpath/splitdrive Linked here; links to this page; shared tags: #ntpath, #stdlib
- tuts/python3/stdlib_module/ntpath/splitroot Linked here; links to this page; shared tags: #ntpath, #stdlib
- tuts/python3/stdlib_module/ntpath Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/ntpath/abspath Linked here; shared tags: #ntpath, #stdlib
- tuts/python3/stdlib_module/ntpath/basename Linked here; shared tags: #ntpath, #stdlib
- tuts/python3/stdlib_module/ntpath/commonpath Linked here; shared tags: #ntpath, #stdlib
- tuts/python3/stdlib_module/ntpath/commonprefix Linked here; shared tags: #ntpath, #stdlib
- tuts/python3/stdlib_module/ntpath/dirname shared tags: #ntpath, #stdlib
- tuts/python3/stdlib_module/ntpath/exists shared tags: #ntpath, #stdlib
- tuts/python3/stdlib_module/ntpath/expanduser shared tags: #ntpath, #stdlib