How to decode a quoted URL in Python?
Posted on In TutorialHow to decode a quoted URL in Python? For example, an quoted URL as follows
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.
$ 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()`.