On this page
posixpath.splitroot
Prev: posixpath.splitext | Up: posixpath
Rel: posixpath.abspath, posixpath.basename, posixpath.commonpath, posixpath.commonprefix
Ref: docs.python.org — posixpath.splitroot
Tags: #public #python3 #stdlib #posixpath
Import
import posixpath
from posixpath import splitroot
Signature & Overview
posixpath.splitroot(p)
Split a pathname into drive, root and tail.
Usage
import posixpath
if hasattr(posixpath, 'splitroot'):
assert posixpath.splitroot('/usr/bin') == ('', '/', 'usr/bin')
Gotchas
- Requires Python 3.12+: Returns
('', root, tail)on POSIX.
REPL Inspect
from posixpath import splitroot
help(splitroot)
Linked from
Related notes
- tuts/python3/stdlib_module/posixpath/splitext Linked here; links to this page; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/posixpath/abspath Linked here; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/basename Linked here; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/commonpath Linked here; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/commonprefix Linked here; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/dirname shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/exists shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/expanduser shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/expandvars shared tags: #posixpath, #stdlib