1. 安装requests
pip install requests
2. 代码:
代码语言:javascript复制import requests
url = "http://www.lance.cn/myweb/request"
headers = {'content-type': 'application/json'}
requestData = {"name": "lance", "age": "28"}
ret = requests.post(url, json=requestData, headers=headers)
if ret.status_code == 200:
text = json.loads(ret.text)
print(text)