ID EN
Pathlib

root

Python 3.11

A string representing the (local or global) root, if any:

Syntax

PYTHON
PurePath.root

Examples

Example 1
PYTHON
>>> PureWindowsPath('c:/Program Files/').root
'\\'
>>> PureWindowsPath('c:Program Files/').root
''
>>> PurePosixPath('/etc').root
'/'
Example 2
PYTHON
>>> PureWindowsPath('//host/share').root
'\\'
Example 3
PYTHON
>>> PurePosixPath('//etc').root
'//'
>>> PurePosixPath('///etc').root
'/'
>>> PurePosixPath('////etc').root
'/'

See Also

PurePosixPath