from urllib import parsekey_word = "中文"url = 'https://s.weibo.com/weibo/' + parse.quote(key_word,encoding='utf8')print(url)#https://s.weibo.com/weibo/%E4%B8%AD%E6%96%87
key_word2= '简体中文'print(parse.urlencode({'key':key_word2},encoding='utf8'))print(parse.quote(key_word2))编码urlencode、quote,解码unquote# key=%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87# %E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87
来源:https://www.cnblogs.com/python001-vip/p/12171976.html