Converting url encoded string(utf-8) to string in python? -
i have url encoded token(utf-8)= "ec%2d2ec7"
, want convert "ec-2ec7"
i.e convert %2d
-
.
>>> token = "ec%2d2ec7" >>> token.encode("utf-8") 'ec%2d2ec7'
i tried urllib.quote
same result. problem token in utf-8
can't convert? can do?
python version: 2.7.10
you can use urllib.unquote
:
from urllib import unquote print unquote("ec%2d2ec7")
another way use requests.utils.unquote
:
from requests.utils import unquote print unquote("ec%2d2ec7")
output:
ec-2ec7
Comments
Post a Comment