私のウェブサイトとクライアント側のスクリプトとの間の通信を試みています。 PythonクライアントはPOSTをPHPファイルに送信し、それがPOSTファイルが出力されていることを表示します。開発の次のステップに進むことができます。しかし何らかの理由で、私はHTML5形式でしか投稿できず、Python 3.5.2要求モジュールでは投稿できません。PythonとPHPの間のPOSTが機能しませんか?
<?php
$data = ((!empty($_POST['data'])) ? $_POST['data'] : 'N/A');
echo $data;
?>
ザ・パイソン:
>>> import requests
>>> url = "www.example.com/coords.php"
>>> data = "This is a string"
>>> r = requests.post(url, data)
>>> r.content
b'N/A'
HTML5作品:
この
はPHPで<html>
<head>
</head>
<body>
<form method="post" action="www.example.com/coords.php">
<input type="text" name="data">
<input type="submit" name="submit">
</form>
</body>
</html>
あなたは受け入れられた答えを変更した理由を説明してくれませんか? – Dekel