标签:urllib port 拼接 rom new 方便 https host login
利用urllib的parse拼接、编码、解码url
from urllib import parse #导入parse
host = ‘http://www.123.cn‘
login_url = ‘api/login‘
goods_urls = ‘/api/goods‘
new_url = parse.urljoin(host,login_url) #拼接url,不管你有没有输入/,拼接的时候会自动帮你加上,拼接url很方便
result = parse.unquote_plus(‘https://www.baidu.com/s?wd=%E7%99%BE%E6%B5%8B‘) #url解码;unquote也是解码,plus解得多些
s = parse.quote_plus("https://www.baidu.com/s?wd=今天中午吃什么")#url编码;quote也是编码,plus编的多些
标签:urllib port 拼接 rom new 方便 https host login
原文地址:https://www.cnblogs.com/lsl1230/p/11930039.html