如何将数据从python传递到php?

2024-04-26 09:30:08 发布

您现在位置:Python中文网/ 问答频道 /正文

我试过这个代码(Python-side)。。。在

import requests
import json

keys = {"name": "John"}
headers = {'Content-type': 'application/x-www-form-urlencoded', 'Accept': 'text/plain'}

r = requests.post("http://localhost/Python_/test.php", data = keys, headers = headers)

print r.url
print r.status_code

在php方面,我正在尝试获取名称。。在

^{pr2}$

我得到了这个错误。。 注意::未定义的索引:C:\xampp\htdocs\Python中的键_\测试.php在线8

我在REST客户机上尝试过,代码显示REST客户机上的名称,但是在localhost上出现了这个错误。在


Tags: 代码nameimport名称restjsonlocalhost客户机