Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
例如,URL 请求是这样的:
http://any-server.org/cgi-bin/test.cgi?a=1&b=2&b=20&b=200
[2,20,200]是否可以在 CGI 或任何 Web 框架中获取 b 的三个值作为列表?
[2,20,200]
谢谢!
使用.getall():
.getall()
b = request.GET.getall('b') # ['2', '20', '200']
.getall()是MultiDict类的方法;的各种参数,request包括和是实例。项目文档(Pyramid 请求所基于的)可以提供更多信息。.GET.POST.paramsMultiDictWebOb
MultiDict
request
.GET
.POST
.params
WebOb
您使用哪种语言?
以上将在 .NET 中按您的预期工作,我希望在 php 和其他语言中类似。
// 根据反馈扩展答案
ASP.NET 似乎将这些值分组到一个逗号分隔的列表中,但这样做的真正方法应该是file.html?a=1&b[]=1&b[]=2&b[]3. 然后,这应该由服务器转换为值数组。
file.html?a=1&b[]=1&b[]=2&b[]3
您也可以使用file.html?a=1&b=1,2,3. 这将在服务器上转换为字符串,并且可以用逗号拆分以获得数组。
file.html?a=1&b=1,2,3