为了账号安全,请及时绑定邮箱和手机立即绑定

远端RESTful API调用

远端RESTful API调用

API
慕运维8079593 2018-07-24 21:21:19
GET /api/accounts HTTP/1.1 Content-Type: application/json X-Access-Token: username:token这种 API,Python 要怎么调用啊??POST 登录生成 token 以后要怎么调用啊??? 求告知
查看完整描述

2 回答

?
泛舟湖上清波郎朗

TA贡献1818条经验 获得超3个赞

import requests

r = requests.get(url)


查看完整回答
反对 回复 2018-07-28
?
一只名叫tom的猫

TA贡献1906条经验 获得超2个赞

import requests
token = '从你存储的地方取值'
headers = {
    'Content-Type': 'application/json',
    'X-Access-Token': 'username:{0}'.format(token)
}

r = request.get('/api/accounts', headers=headers)
print r.text


查看完整回答
反对 回复 2018-07-28
  • 2 回答
  • 0 关注
  • 1167 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信