Python converts a string into a urlencode, or a URL-encoded string decode: Method1: The quote method in Urlencode:urllib>>> fromUrllibImportQuote>>>Quote': ')'%3a '>>>Quote' http://www.baidu.com ')' http%3a//www.baidu.com 'The Unquote method in Urldecode:urllib>>> fromUrllibImportUnquote>>>Unquote (' http%3a//www.baidu.com ')' http://www.baidu.com 'Method two Urllib.urlencode () Unfortunately, this function can only receive key-The value pair format data. That is only for dict and does not currently provide the UrlDecode method>>> ImportUrllib>>>Params=Urllib.urlencode ({' spam ':1,' eggs ':2,' Bacon ':0})>>>Params=Urllib.urlencode ({' spam ':1,' eggs ':2,' Bacon ':0})>>>Params# # #自动转化成下面url的参数形式' Eggs=2&bacon=0&spam=1 '>>>F=Urllib.urlopen ("Http://www.musi-cal.com/cgi-bin/query?"%s" %Params>>> PrintF.read ()
UrlEncode and UrlDecode in Python