>>> prourl=u'http://product.gongchang.com/s3946/CNS2900183019.html?gct=13.0.1-4&a=1&b=2&c=3'
>>> import urlparse
>>> import urllib
>>> urlobj=urlparse.urlparse(prourl.encode("utf8"))
>>> h=list(urlobj)
>>> h
['http', 'product.gongchang.com', '/s3946/CNS2900183019.html', '', 'gct=13.0.1-4&a=1&b=2&c=3', '']
>>> query=urlobj.query
>>> query
'gct=13.0.1-4&a=1&b=2&c=3'
>>> para_dict=dict(urlparse.parse_qsl(query)) 空值不算 ||para_dict=dict(urlparse.parse_qsl(query,1))
>>> para_dict
{'a': '1', 'c': '3', 'b': '2', 'gct': '13.0.1-4'}
>>> prlist[4] = urllib.urlencode(para_dict)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'prlist' is not defined
>>> h[4] = urllib.urlencode(para_dict)
>>> h
['http', 'product.gongchang.com', '/s3946/CNS2900183019.html', '', 'a=1&c=3&b=2&gct=13.0.1-4&d=4', '']
>>> urlparse.ParseResult(*h).geturl()
'http://product.gongchang.com/s3946/CNS2900183019.html?a=1&c=3&b=2&gct=13.0.1-4&d=4'