Tornado Documentation
http://www.v2ex.com/tornado/
Tornado on GitHub
https://github.com/facebook/tornado/
Tornado Gists
http://tornadogists.org/
qloog
V2EX  ›  Tornado

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

  •  
  •   qloog · Jun 16, 2014 · 9584 views
    This topic created in 4377 days ago, the information mentioned may be changed or developed.
    比如表单:
    <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, 如何做? 求教各位~
    4 replies    2014-07-25 15:01:47 +08:00
    qloog
        2
    qloog  
    OP
       Jun 20, 2014
    @riaqn 这个貌似不是获取数组的吧?
    shajiquan
        3
    shajiquan  
       Jul 25, 2014
    HTML 表单里的 name=order[x] 全部换成 order。

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

    print(type(orders), orders)
    shajiquan
        4
    shajiquan  
       Jul 25, 2014
    Gists:

    [get_list_from_post_in_tornado](https://gist.github.com/shajiquan/f937cf831ab8bd7511c1)
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2616 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 15:54 · PVG 23:54 · LAX 08:54 · JFK 11:54
    ♥ Do have faith in what you're doing.