>>> from urllib import parse>>> url = 'http://www.baidu.com/s?wd=codeif.com&spt=1'>>> bits = list(parse.urlparse(url))>>> bits['http', 'www.baidu.com', '/s', '', 'wd=codeif.com&spt=1', '']>>> qs = parse.parse_qs(bits[4])>>> qs{'wd': ['codeif.com'], 'spt': ['1']}>>> qs['wd'] = ['sina','@www']>>> qs['pg'] = [8]>>> del qs['spt']>>> qs{'pg': [8], 'wd': ['sina', '@www']}>>> bits[4] = parse.urlencode(qs, True)>>> bits['http', 'www.baidu.com', '/s', '', 'pg=8&wd=minicn&wd=%40www', '']>>> url = parse.urlunparse(bits)>>> url'http://www.baidu.com/s?pg=8&wd=minicn&wd=%40www'>>>