params是一个有序字典,里面redirect_uri = r'http%3A%2F%2Fqs.test.xxxxx.com%2F',特意加了r,防止转义。
执行完get请求的时候,发现结果一直不通,查看url发现参数变成redirect_uri = 'http%253A%252F%252Fqs.test.xxxxx .com%252F'了,%全部变成%25了,请问是什么原因呢?
>>>print(params)
OrderedDict([('appid', 'zt7FYIxgm-Waue4L1p'), ('redirect_uri', 'http%3A%2F%2Fqs.test.xxxxx.com%2F'), ('response_type', 'code'), ('scope', 'userinfo,user_id,userprofile'), ('state', 'NKn64fGOTv1L66Eh')])
>>>res = requests.get(url,params=params,headers=headers)
>>>print(res.url)
https://connect.zto.com/oauth2/authorize?appid=zt7FYIxgm-Waue4L1p&redirect_uri=http%253A%252F%252Fqs.test.xxxxx
.com%252F&response_type=code&scope=userinfo%2Cuser_id%2Cuserprofile&state=NKn64fGOTv1L66Eh
相似问题