bottle 中没有值的参数
parameters without value in bottle
在我的 hooks/routes 我使用:
debug = request.GET.get('debug', False)
它适用于:
http://test.internal.local:8888/probe?debug=anything
但是我怎样才能让它只使用标志而不使用类似的值?
http://test.internal.local:8888/probe?debug
谢谢
您仍然可以获得 debug
标志,但值将是空字符串(''
)。
所以检查你是否得到那个标志很简单:
debug = request.GET.get('debug') # if there is no debug flag you get `None`
if debug is not None:
# you have your debug flag
在我的 hooks/routes 我使用:
debug = request.GET.get('debug', False)
它适用于:
http://test.internal.local:8888/probe?debug=anything
但是我怎样才能让它只使用标志而不使用类似的值?
http://test.internal.local:8888/probe?debug
谢谢
您仍然可以获得 debug
标志,但值将是空字符串(''
)。
所以检查你是否得到那个标志很简单:
debug = request.GET.get('debug') # if there is no debug flag you get `None`
if debug is not None:
# you have your debug flag