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

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -