Last active
August 8, 2020 16:37
-
-
Save Miouyouyou/b42ab007c51112510e740e8e686a1e3f to your computer and use it in GitHub Desktop.
Python : URI file:// to OS path
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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