from operator import pos #导入包 定义要使用那个类 import requests import json url = 'http://123.56.22.39:48083/web/v2/user/userLogin' date={ 'userName':'admin', 'password':'admin' } r=requests.post(url=url,data=date) print(r.status_code) print(r.text) print(r.json()['data']['token']) url2 = 'http://123.56.22.39:48083/web/v2/user/logout' date1={ 'userId':1, 'token':r.json()['data']['token'] } r2 = requests.post(url=url2,data=date1) print(r2.status_code) print(r2.text)
返回数据为
200
{"code":0,"msg":"请求成功","userId":0,"token":null,"data":{"role":1,"videoPower":"1","snAuthPower":"1","userId":1,"token":"9f88cdad3c3b4e748e5367fb55cba90e"}}
9f88cdad3c3b4e748e5367fb55cba90e #第一个接口返回的数据
200
{"code":0,"msg":"请求成功","userId":0,"token":null,"data":null}
第一个接口返回的token数据 作为第二个接口token的入参。