Decoding
We can use urllib module to do this. This is in Python 2.7x — and Python 3+ (added).
➡️ Documentation for urllib.unquote() Python 2 utility.
➡️ Documentation for urllib.parse.unquote() Python 3 utility.
Encoding
The opposite of that function is urllib.quote(string) (Python 2) with an additional (optional) parameter to define a custom safe characters list. This is the documentation.
For Python 3, there is urllib.parse.quote(). But there are others: quote_plus and quote_from_bytes.
This is the urllib.parse.quote() documentation for Python 3.
