Getting the array as GET query parameters in Python

前端 未结 2 1077
抹茶落季
抹茶落季 2020-12-24 05:17

I know in php I could just use $_GET[\'key1\'][\'key2\'] to retrieve GET data that is sent in the form of an array but is that something possible in Python as I

2条回答
  •  孤独总比滥情好
    2020-12-24 05:54

    request.args is a MultiDict instance (MultiDict, Flask request api).

    request.args[key] ## returns a single value, the first if there are multiple
    request.args.getlist(key) ## returns a list
    

    If you want to submit structures more complex than can be encoded using simple key:vals, consider sending a json encoded object.

    Also, look at the jQuery recursive param serialisation pattern, and the jquery-unparam lib which can deserialise it.

提交回复
热议问题