Flask request.args.get获取所有参数(Python) [英] Flask request.args.get get all params (Python)
问题描述
我如何从烧瓶中的URL解析所有GET参数? 我尝试使用 request.args.get ,但它可与特定的GET参数(预定义)一起使用,但是我需要从我的大型URL进行解析(例如:
how i can parse all GET params from URL in flask? I tried use request.args.get, but it works with specific GET params (pre defined), but i need parse it all from my large URL (ex: http://site.ru/?a=1&b=2&c=3&some_string=string...)
推荐答案
如果使用request.args
,它将为字典提供GET参数的键值对
If you use request.args
it will provide a dictonary with key-value pairs of the GET parameters
例如:http://website.com/index?arg1=hello&arg2=world
print request.args
>> {"arg1": "hello", "arg2": "world"}
request.args.get(key)
是有用的字典函数,如果未设置参数而不是引发KeyError
The request.args.get(key)
is a useful dictionary function that will return None
if the parameter is not set rather than raising a KeyError
这篇关于Flask request.args.get获取所有参数(Python)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!