在Python中获取数组作为GET查询参数 [英] Getting the array as GET query parameters in Python

查看:569
本文介绍了在Python中获取数组作为GET查询参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道在PHP中,我可以使用 $ _ GET ['key1'] ['key2'] 来检索以数组形式发送的GET数据。是Python中可能的东西,因为我刚刚收到一个字符串,它不被识别为一个数组/列表。

如果有问题,我使用flask / werkzeug。

解决方案

参数名称的深度解析对于PHP AFAIK是独一无二的。只需要一个简单的列表,只需传递几个具有相同名称的参数并使用 request.args.getlist(< paramname>) documentation )。



否则你有自己解析查询字符串。


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 just receive a string and it's not recognized as an array/list.

I use flask/werkzeug if that matters.

解决方案

The deep parsing of argument names is unique for PHP AFAIK.

If you need just a simple list, just pass several parameters with the same name and use request.args.getlist(<paramname>) (documentation).

Otherwise you have to parse the query string yourself.

这篇关于在Python中获取数组作为GET查询参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆