Decode escaped characters in URL Decode escaped characters in URL python python

Decode escaped characters in URL


Official docs.

urllib.unquote(string)

Replace %xx escapes by their single-character equivalent.

Example: unquote('/%7Econnolly/') yields '/~connolly/'.

And then just decode.


Update:For Python 3, write the following:

import urllib.parseurllib.parse.unquote(url)

Python 3 docs.


And if you are using Python3 you could use:

import urllib.parseurllib.parse.unquote(url)


or urllib.unquote_plus

>>> import urllib>>> urllib.unquote('erythrocyte+membrane+protein+1%2C+PfEMP1+%28VAR%29')'erythrocyte+membrane+protein+1,+PfEMP1+(VAR)'>>> urllib.unquote_plus('erythrocyte+membrane+protein+1%2C+PfEMP1+%28VAR%29')'erythrocyte membrane protein 1, PfEMP1 (VAR)'