POST挂架,在php中获得类似的数组
我有一个动态表单,我必须创建一些post数组来输入一些id 例如: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
<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']