Python 简单的带参数Post请求


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))


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM