Skip to main content

Python: How to Unescape String (DecodeURI in JavaScript)

We can use urllib module to do this. Oh and by the way, this is on Python 2.7x and Python 3+.

This is the documentation for urllib.unquote Python 2 utility.

This is the documentation for urllib.parse.unquote Python 3 utility.


The opposite of that function is urllib.quote(string) (Python 2) with additional argument to create 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.

Last modified on

Comments