Template request | Bug report | Generate Data Product
Tags: #python #urllib #string #url #convert #library
Author: Florent Ravenel
Description: This notebook will show how to convert a URL to a string using urllib.
References:
import urllib.parse
url
: URL to be converted to string
url = "https://www.pythonforbeginners.com/urllib/how-to-use-urllib-in-python"
The unquote() function in urllib.parse converts percent-encoded characters in the URL back to their original form. In this example, the URL is already in string form, so unquote() simply returns the same string.
If the URL had any percent-encoded characters, they would be decoded by unquote().
string = urllib.parse.unquote(url)
print(string)