在Python中获取数组作为GET查询参数

编程入门 行业动态 更新时间:2024-10-27 06:25:35
本文介绍了在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查询参数

本文发布于:2023-10-29 13:21:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1539803.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数组   参数   Python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!