ID EN
Pathlib

as_uri

Python 3.11

Represent the path as a file URI. ValueError is raised if the path isn’t absolute.

Syntax

PYTHON
PurePath.as_uri()

Examples

Example 1
PYTHON
>>> p = PurePosixPath('/etc/passwd')
>>> p.as_uri()
'file:///etc/passwd'
>>> p = PureWindowsPath('c:/Windows')
>>> p.as_uri()
'file:///c:/Windows'

See Also

ValueError