Import Urllibrawurl=xxxurl=urllib.unquote (Rawurl)
Module used: Urllib
Function used: Urllib.unquote ()
Case
Import"%e6%b2%b3%e6%ba%90"= urllib.unquote (rawurl) Print URL
Output
Heyuan
Problem extension
Urllib.unquote () is intended to decode the URL encoding, which corresponds to the function of the encoding function urllib.quote ()
>>> Import urllib>>> urllib.quote ("Heyuan") '%e6%b2%b3%e6%ba%90
Why do URLs need to be encoded and decoded?
Usually if something needs to be coded, it means that something is not suitable for transmission. There are a variety of reasons, such as size too large to contain privacy data. For URLs, the reason for encoding is because some characters in the URL cause ambiguity.
For example, the URL parameter string uses the Key=value key value pair to pass the parameter, separating the key-value pairs with a & symbol, such as/S?Q=ABC&ie=utf-8. If your value string contains = or &, then it is bound to cause the server parsing error to receive the URL, so the ambiguous & and = symbol must be escaped, that is, encoded.
Another example is that the URL is encoded in ASCII instead of Unicode, which means that you cannot include any non-ASCII characters in the URL, such as Chinese. Otherwise, Chinese can cause problems if the client browser and the server-side browser support different character sets.
Python for URL decoding