ID EN
Pathlib

drive

Python 3.11

A string representing the drive letter or name, if any:

Syntax

PYTHON
PurePath.drive

Examples

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