模仿yun登录:
def yun_login(username,password):
#要请求的路由
url = "http://yun.zenm.vip/iot/account/login/"
#需要传的参数(用户名和密码)
data = {
‘username‘:‘123‘,
‘password‘: ‘123456‘
}
data1 = json.dumps(data)
#请求头
header = {
‘Content-Type‘: ‘application/json‘
}
res = requests.post(url=url, headers=header, data=data1)
json_data = res.json()
print(json_data)
return json_data