ID EN
Pathlib

name

Python 3.11

A string representing the final path component, excluding the drive and root, if any:

Syntax

PYTHON
PurePath.name

Examples

Example 1
PYTHON
>>> PurePosixPath('my/library/setup.py').name
'setup.py'
Example 2
PYTHON
>>> PureWindowsPath('//some/share/setup.py').name
'setup.py'
>>> PureWindowsPath('//some/share').name
''