Python-提交json请求

Posted 梦之海岛

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python-提交json请求相关的知识,希望对你有一定的参考价值。

python

import requests
import json
url = 'http://IP:端口/路径'
s = json.dumps('key1': 'value1', 'key2': 'value2')
h = 'Content-Type': 'application/x-www-form-urlencoded'
r = requests.post(url, data=s, headers=h)
print(r.text)

php后端

$data = json_decode(file_get_contents('php://input'), true);

以上是关于Python-提交json请求的主要内容,如果未能解决你的问题,请参考以下文章