Flask request.args.get获取所有参数(Python)

Kon*_*nov 4 python get flask

我如何从烧瓶中的URL解析所有GET参数?我尝试使用request.args.get,但它适用于特定的GET参数(预定义),但我需要从我的大URL解析它(例如:http://site.ru/?a = 1&b = 2& c = 3&some_string = string ..)

Mik*_*ike 17

如果你使用request.args它将提供具有GET参数的键值对的dictonary

例如: http://website.com/index?arg1=hello&arg2=world

print request.args
>> {"arg1": "hello", "arg2": "world"}
Run Code Online (Sandbox Code Playgroud)

request.args.get(key)是一个有用的字典函数,None如果没有设置参数而不是引发a ,它将返回KeyError