python请求调用包含加号字符的url

时间:2016-12-22 18:58:46

标签: python python-requests

我想调用一个看起来像这样的api端点 http://api.example.com/user/jhon+doe?field=full&key=somestring。当我使用python请求调用此url时,由于用户名错误,我总是得到错误的结果。这是我的代码

import requests as req
url = 'http://api.example.com/user/jhon+doe?field=full&key=somestring'
r = req.get(ur)
data = r.json() # return wrong result
print r.url # output wrong url ,, http://api.example.com/user/jhon 

0 个答案:

没有答案