On this page
posixpath.split
Prev: posixpath.samestat | Up: posixpath | Next: posixpath.splitdrive
Rel: posixpath.abspath, posixpath.basename, posixpath.commonpath, posixpath.commonprefix
Ref: docs.python.org — posixpath.split
Tags: #public #python3 #stdlib #posixpath
Import
import posixpath
from posixpath import split
Signature & Overview
posixpath.split(p)
Split a pathname. Returns tuple "(head, tail)" where "tail" is everything after the final slash. Either part may be empty.
Usage
import posixpath
assert posixpath.split('/a/b/file.txt') == ('/a/b', 'file.txt')
Gotchas
- Returns
(dirname, basename).
REPL Inspect
from posixpath import split
help(split)
Linked from
Related notes
- tuts/python3/stdlib_module/posixpath/samestat Linked here; links to this page; shared tags: #posixpath, #stdlib
- tuts/python3/stdlib_module/posixpath/splitdrive 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