Flask request.args.get 获取所有参数(Python) [英] Flask request.args.get get all params (Python)

查看:123
本文介绍了Flask request.args.get 获取所有参数(Python)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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) 是一个有用的字典函数,如果参数未设置,它将返回 None 而不是引发 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆