How to decode a quoted URL in Python?

Posted on In Tutorial

How to decode a quoted URL in Python? For example, an quoted URL as follows

should be decoded to银行/

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 = "";
>>> urllib.parse.unquote_plus(url)

In Python 2, the similar function is `urllib.parse.parse_qs()`.

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.