0 安装库+引用库
安装代码
pip install requests
引用库
import requests # http请求
import json # json数据格式
1 发送 http请求
# 需要发送http请求的url地址
url = "https://xxx.xxx.xxx"
# 设置header
headers = {'content-type': "application/json"}
# json数据
body = {"a":"a","b":"b"}
# 发送请求
response = requests.post(url, data = json.dumps(body), headers = headers)
2 读取 http response
# 文本化返回值
response_msg = response.text