使用Python Flask检查Cookie [英] Check for a cookie with Python Flask
本文介绍了使用Python Flask检查Cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想通过这个Flask调用来获取cookie(例如国家
)。
I would like to get a cookie (e.g. country
) with this Flask call.
data = request.cookies.get("country")
我如何告诉cookie是否存在?
How can I tell if the cookie exists?
推荐答案
request.cookies
是 dict
,因此:
from flask import request
if 'country' in request.cookies:
# do something
else:
# do something else
这篇关于使用Python Flask检查Cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文