Tornado 如何获取 form 表单提交过来的数组?

2014 年 6 月 16 日
 qloog
比如表单:
<form action="">
<input type="input" name="order[1]" value=2 />
<input type="input" name="order[2]" value=4 />
<input type="input" name="order[3]" value=1 />
<input type="input" name="order[4]" value=3 />
</form>

那么我在后端如何获取到这个数组,主要是为了取到 order里的key和表单里对应的value, 如何做? 求教各位~
9500 次点击
所在节点    Tornado
4 条回复
riaqn
2014 年 6 月 16 日
qloog
2014 年 6 月 20 日
@riaqn 这个貌似不是获取数组的吧?
shajiquan
2014 年 7 月 25 日
HTML 表单里的 name=order[x] 全部换成 order。

handlers 里:
orders = self.get_body_arguments("order",None)

print(type(orders), orders)
shajiquan
2014 年 7 月 25 日
Gists:

[get_list_from_post_in_tornado](https://gist.github.com/shajiquan/f937cf831ab8bd7511c1)

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://study.congcong.us/t/117840

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX