urlencode()
传入参数类型:字典
功能:将存入的字典参数编码为URL查询字符串,即转换成以key1=value1&key2=value2的形式
导入:from urllib.parse import urlencode
例如:
from urllib.parse import urlencode
baseurl = 'http://image.so.com/zj?'
params = {
'ch' : 'beauty',
'sn' : str(1),
'listtype' : 'new',
'temp' : '1'
}
url = baseurl + urlencode(params)
print(url)
得到的结果为:http://image.so.com/zj?ch=beauty&sn=1&listtype=new&temp=1