gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-30 01:42:36 40 4
gpt4 key购买 nike

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

最佳答案

如果您使用request.args,它将提供一个包含 GET 参数键值对的字典

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

print request.args
>> {"arg1": "hello", "arg2": "world"}

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

关于python - Flask request.args.get 获取所有参数(Python),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41229710/

40 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com