爬虫链接编码

from urllib import parse

key_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
posted @ 2020-01-09 16:03  import*  阅读(175)  评论(0编辑  收藏  举报