我想知道是否可以从这个查询字符串中获取值?
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更多推荐
是否可以从具有相同名称的查询字符串中获取值?
发布评论