Flask request.args.get get all params (Python)

这一生的挚爱 提交于 2020-05-11 06:36:30

问题


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...)


回答1:


If you use request.args it will provide a dictonary with key-value pairs of the GET parameters

Ex: 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



来源:https://stackoverflow.com/questions/41229710/flask-request-args-get-get-all-params-python

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!