PyDocs

Nav

Internet Protocols and Support

pathname2url

urllib.request

function (source) not WASI
  • pathname2url(path, *, add_scheme=False)
Convert the given local file system path to a file URL.

The 'file:' scheme prefix is omitted unless *add_scheme*
is set to true.
Changed in 3.14
  • 3.14: Windows drive letters are no longer converted to uppercase, and : characters not following a drive letter no longer cause an OSError exception to be raised on Windows.
  • 3.14: Paths beginning with a slash are converted to URLs with authority sections. For example, the path /etc/hosts is converted to the URL ///etc/hosts.
  • 3.14: The add_scheme parameter was added.
1 Example
>>> from urllib.request import pathname2url
>>> path = 'C:\\Program Files'
>>> pathname2url(path, add_scheme=True)
'file:///C:/Program%20Files'
from the Python docs
See Also
No see-alsos for urllib.request/pathname2url
0 Notes
No notes for pathname2url