总结:
1、data数据格式
2、php post 格式无需json_encode(关联数组,所以可以绕弯) 参考:http://bbs.csdn.net/topics/390645553?page=1
import requests data={ "xxx":xxx, "yyy":yyy, } values = { "data":json.dumps(data) } files = { 'isImg': open('test.jpg').read() } res = requests.post("http://------------", data=values,files=files) print(res.text);
php:
$data = array( "xxx"=>$xxx, "yyy"=>$yyy, ); $data =array( 'data'=>json_encode($data), 'isImg'=>"@$msg"); $url = $this->url."-------"; $ret = $this->_request($url,'POST',$data); //curl部分: //if($method=='POST'){ // curl_setopt($ch, CURLOPT_POST, 1); // curl_setopt($ch, CURLOPT_POSTFIELDS, $data); // }
浙公网安备 33010602011771号