我试过这段代码(Python 端)...
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 方面,我正在尝试获取名称..
print_r($_POST['keys']);
我收到这个错误..
注意:8
我在 REST 客户端上试过了,代码在 REST 客户端上显示了名称,但在本地主机上出现了这个错误。
最佳答案
您的帖子数据将是 keys
字典。
你的 php 代码应该是 print_r($_POST['name']);
关于python - 如何将数据从 python 传递到 php?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28590542/