服务端接收json数据,返回json数据
POST请求发出端Python代码:
# 发出POST请求
url ='http://127.0.0.1:8888/login'
headers = {'Content-Type':'application/json'}
data = {"user": "xiaoming", "password": "12345678"}
data_json = json.dumps(data)
post_res_str = requests.post(url, data=data_json, headers=headers)
# 对返回结果进行解析()
result = post_res_str.text
result_json = json.loads(result)
网友评论