📜  python request post with json with headers - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:11.078000             🧑  作者: Mango

代码示例1
url = "http://localhost:8080"
data = {'sender': 'Alice', 'receiver': 'Bob', 'message': 'We did it!'}
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
r = requests.post(url, data=json.dumps(data), headers=headers)