Python使用request调用htt

2020-01-03 11:29:25 浏览数 (1)

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)

0 人点赞