Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/326.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
POST挂架,在php中获得类似的数组_Php_Python_Pylons - Fatal编程技术网

POST挂架,在php中获得类似的数组

POST挂架,在php中获得类似的数组,php,python,pylons,Php,Python,Pylons,我有一个动态表单,我必须创建一些post数组来输入一些id 例如: <input type="checkbox" name="field[124][]" value="1"> <input type="checkbox" name="field[124][]" value="2"> 如何像在PHP中一样在pylons post数组中创建 谢谢。您可以使用multidict对象的.getall(),例如: html: 获取此列表的另一种方法是使用.dict_of_lis

我有一个动态表单,我必须创建一些post数组来输入一些id

例如:

<input type="checkbox" name="field[124][]" value="1">
<input type="checkbox" name="field[124][]" value="2">
如何像在PHP中一样在pylons post数组中创建

谢谢。

您可以使用multidict对象的.getall(),例如:

html:


获取此列表的另一种方法是使用.dict_of_list(),例如:

控制器:

values = request.POST.getall('field[124][]')
# >>> values
# [u'1', u'2']
d = request.POST.dict_of_lists()
values = d['field[124][]']
# >>> d
# {'field[124][]':[u'1', u'2']}
# >>> values
# [u'1', u'2']
<input type="checkbox" name="field[124][]" value="1">
<input type="checkbox" name="field[124][]" value="2">
values = request.POST.getall('field[124][]')
# >>> values
# [u'1', u'2']
d = request.POST.dict_of_lists()
values = d['field[124][]']
# >>> d
# {'field[124][]':[u'1', u'2']}
# >>> values
# [u'1', u'2']