给出了request_test.py(在官方要求文档http://docs.python-requests.org/en/latest/user/quickstart/#more-complicated-post-requests上复制并粘贴了一个示例)
import requests
payload = {'key1': ['value1', 'value2']}
r = requests.post('http://localhost/testserv/test.php', data = payload)
和test.php
<?php
ob_flush();
ob_start();
var_dump($_POST);
file_put_contents("dump.txt", ob_get_flush());
当我运行脚本时,dump.txt的内容是
array(1) {
["key1"]=>
string(6) "value2"
}
问题是,如何使用请求模块发送带有发帖请求的非基本变量?