是否可以从具有相同名称的查询字符串中获取值?

编程入门 行业动态 更新时间:2024-10-20 09:32:45
本文介绍了是否可以从具有相同名称的查询字符串中获取值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想知道是否可以从这个查询字符串中获取值?

I want to know if it's possible to get values from this query string?

'?agencyID=1&agencyID=2&agencyID=3'

为什么我必须使用这样的查询字符串?我有一个带有 10 个复选框的表单.我的用户应该向我发送他/她感兴趣的新闻机构的 ID.以便查询包含多个同名值的字符串.新闻机构的总数是可变的,它们是从数据库中加载的.我正在使用 Python Tornado 来解析查询字符串.

Why I have to use a query string like this? I have a form with 10 check boxes. my user should send me ID of news agencies which he/she is interested in. so to query string contains of multiple values with the same name. total count of news agencies are variable and they are loaded from database. I'm using Python Tornado to parse query strings.

推荐答案

阅读龙卷风文档,这似乎可以满足您的需求

Reading the tornado docs, this seems to do what you want

RequestHandler.get_arguments(name, strip=True)

返回一个列表具有给定名称的参数.如果参数不存在,则返回一个空列表.返回值始终为 unicode.

Returns a list of the arguments with the given name. If the argument is not present, returns an empty list. The returned values are always unicode.

就这样

ids = self.get_arguments('agencyID')

请注意,这里我使用了 get_arguments,还有一个 get_argument 但它只获取一个参数.

Note that here i used get_arguments, there is also a get_argument but that gets only a single argument.

您可以使用

query = self.request.query

更多推荐

是否可以从具有相同名称的查询字符串中获取值?

本文发布于:2023-11-17 12:09:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1609957.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   名称

发布评论

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

>www.elefans.com

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