I have a python program which uses requests. I want to upload data via post request like this:
payload = (('key1', 'value1'), ('key1', 'value2'))
r = requests.post("https://www.example.com/test.php", payload)
print(r.text)
In php I receive this data for testing like this:
<?php
echo var_dump($_POST);?>
In the example of the doc ( http://docs.python-requests.org/en/latest/user/quickstart/#more-complicated-post-requests ) this:
print(r.text)
should be output this:
"form": {
"key1": [
"value1",
"value2"
]}
But in the output array value1 is missing:
array(1) {
["key1"]=>
string(6) "value2"}
Whats wrong here? Where is "value1"?
Try this as your payload in the python
payload = {'key1', ['value1', 'value2']}
this will help your payload with the same key have two values.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.