Url decode UTF-8 in Python

I have spent plenty of time as far as I am newbie in Python.
How could I ever decode such a URL:

    example.com?title=%D0%BF%D1%80%D0%B0%D0%B2%D0%BE%D0%B2%D0%B0%D1%8F+%D0%B7%D0%B0%D1%89%D0%B8%D1%82%D0%B0

to this one in python 2.7: example.com?title==правовая+защита

url=urllib.unquote(url.encode("utf8")) is returning something very ugly.

Still no solution, any help is appreciated.

The data is UTF-8 encoded bytes escaped with URL quoting, so you want to decode :

    url = urllib.unquote(url).decode('utf8')

Demo:

    >>> import urllib 
    >>> url='example.com?title=%D0%BF%D1%80%D0%B0%D0%B2%D0%BE%D0%B2%D0%B0%D1%8F+%D0%B7%D0%B0%D1%89%D0%B8%D1%82%D0%B0'
    >>> urllib.unquote(url).decode('utf8') 
    u'example.com?title=\u043f\u0440\u0430\u0432\u043e\u0432\u0430\u044f+\u0437\u0430\u0449\u0438\u0442\u0430'
    >>> print urllib.unquote(url).decode('utf8')
    example.com?title=правовая+защита

The Python 3 equivalent is urllib.parse.unquote(), which by default handles decoding for you:

    from urllib.parse import unquote

    url = unquote(url)

From: stackoverflow.com/q/16566069