Flask request.args.get 获取所有参数(Python)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41229710/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Flask request.args.get get all params (Python)
提问by Konstantin Rusanov
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...)
我如何从 Flask 中的 URL 解析所有 GET 参数?我尝试使用request.args.get,但它适用于特定的 GET 参数(预定义),但我需要从我的大 URL 解析它(例如:http: //site.ru/?a=1&b=2&c=3& some_string =字符串...)
回答by Mike
If you use request.args
it will provide a dictonary with key-value pairs of the GET parameters
如果您使用request.args
它,它将提供一个带有 GET 参数的键值对的字典
Ex: http://website.com/index?arg1=hello&arg2=world
前任: http://website.com/index?arg1=hello&arg2=world
print request.args
>> {"arg1": "hello", "arg2": "world"}
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
这request.args.get(key)
是一个有用的字典函数,None
如果未设置参数而不是提高参数,它将返回KeyError
回答by Ishan Tomar
[i for i in request.args.keys()]