url解码python
How to decode a quoted URL in Python? For example, an quoted URL as follows
如何在Python中解码带引号的URL? 例如,带引号的网址如下
https://www.example.com/tag/%E9%93%B6%E8%A1%8C/
should be decoded to
应该解码为
https://www.example.com/tag/银行/
In Python 3, we can use `urllib.parse_plus()` (for URL only). One example is as follows.
在Python 3中,我们可以使用urllib.parse_plus() (仅适用于URL)。 一个例子如下。
$ python3
Python 3.6.8 (default, Oct 7 2019, 12:59:55)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib.parse
>>> url = "https://www.example.com/tag/%E9%93%B6%E8%A1%8C/";
>>> urllib.parse.unquote_plus(url)
'https://www.example.com/tag/银行/'
>>>
In Python 2, the similar function is `urllib.parse.parse_qs()`.
在Python 2中,类似的函数是`urllib.parse.parse_qs()`。
翻译自: https://www.systutorials.com/how-to-decode-a-quoted-url-in-python/
url解码python