我有一根弦:
{
'singleQuesResponses': {
'28': '',
'14': '',
'27': '',
'26': ''
},
'org_apache_struts_taglib_html_TOKEN': 'a1553f25303435076412b5ca7299b936',
'quesResponses': {
'some': 'data'
}
}
当我把它贴在pyhton的请求中时,比如:
^{pr2}$那么这个帖子的价值是这样的:
array(3) { ["quesResponses"]=> string(4) "some" ["singleQuesResponses"]=> string(2) "14" ["org_apache_struts_taglib_html_TOKEN"]=> string(32) "a1553f25303435076412b5ca7299b936" }
但我希望:
array(3) { ["quesResponses"]=> array["some"=>'data'] ["singleQuesResponses"]=> string(2) "14" ["org_apache_struts_taglib_html_TOKEN"]=> string(32) "a1553f25303435076412b5ca7299b936" }
我的意思是为什么“some”不以数组的形式通过值发送,而它的唯一第一个键作为字符串发送?在
这就是它的工作原理。将数据参数设置为dict将使请求模块尝试发送它:
它只接受字典的第一级并在正文中编码为x=data&y=other\u数据。在
你应该用json.dumps文件(data)或直接将其分配给json参数。在
^{pr2}$这会将Content-Type头设置为application/json
或者
这不会设置内容类型标头。在
在这种情况下,唯一的方法是用
Get
发送数据,而不是用数据发布它们;您可以在请求模块中使用params。在相关问题 更多 >
编程相关推荐