标签:div ref python基础 query lang 教程 bsp sele hbm
from urllib import parse
#url编码
url = ‘http://www.baidu.com?query = python基础教程‘
url_str = parse.quote_plus(url) #quote 跟quote_plus一样的,后者更牛逼,把汉字变成url编码
print(url_str) #http%3A%2F%2Fwww.baidu.com%3Fquery+%3D+python%E5%9F%BA%E7%A1%80%E6%95%99%E7%A8%8B
#url解码
baidu_url = ‘https://www.baidu.com/s?ie=utf-8&f=3&rsv_bp=1&rsv_idx=1&tn=baidu&wd=python%E5%9F%BA%E7%A1%80%E6%95%99%E7%A8%8B&oq=python&rsv_pq=b6c92ffc00023232&rsv_t=be4d%2FdgIVLHbmdj5jU9bfpJTXGIAcO4y2u%2BfKsxWWJW2wIKbEuXL6tNXiug&rqlang=cn&rsv_enter=1&inputT=878&rsv_sug3=9&rsv_sug1=3&rsv_sug7=100&rsv_sug2=0&prefixsug=python&rsp=1&rsv_sug4=2134&rsv_sug=1‘
unbaidu_url = parse.unquote_plus(baidu_url)
print(unbaidu_url)
标签:div ref python基础 query lang 教程 bsp sele hbm
原文地址:https://www.cnblogs.com/pengzhuopeng/p/9090976.html