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

猜你喜欢

转载自blog.csdn.net/smallfox233/article/details/128109072