Transform URL string into normal string in Python (%20 to space etc)

For python 2:

>>> import urllib2
>>> print urllib2.unquote("%CE%B1%CE%BB%20")
αλ 

For python 3:

>>> from urllib.parse import unquote
>>> print(unquote("%CE%B1%CE%BB%20"))
αλ

And here’s code that works in all versions:

try:
    from urllib import unquote
except ImportError:
    from urllib.parse import unquote

print(unquote("%CE%B1%CE%BB%20"))

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)