Post请求
import json
import requests
host = "192.168.1.111"
port = "9999"
def get_data():
req_url = f"http://{host}:{port}/professional/python/getTaskGivePython"
pre_data = {"key": "value"}
headers = {"content-type": "application/json"}
param = json.dumps(pre_data)
try:
resp = requests.post(req_url, data=param, headers=headers)
resp.raise_for_status()
print(resp.status_code)
return resp.json()
except Exception as Error:
print(Error)
data = get_data()
print(type(data))