Skip to content

Instantly share code, notes, and snippets.

@Miouyouyou
Last active August 8, 2020 16:37
Show Gist options
  • Select an option

  • Save Miouyouyou/b42ab007c51112510e740e8e686a1e3f to your computer and use it in GitHub Desktop.

Select an option

Save Miouyouyou/b42ab007c51112510e740e8e686a1e3f to your computer and use it in GitHub Desktop.
Python : URI file:// to OS path
from urllib.parse import unquote_plus, urlparse # Helps convert file:// URI to PATH URI
import pathlib
def file_uri_to_os_path(uri):
u = urlparse(uri)
p = unquote_plus(u.path)
return pathlib.Path(u.netloc, p)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment