Python 3.x 如何在python flask中检查request.form.get值是否为null?
我正在用python Flask框架启动简单的CURD操作,我想知道当用户提交表单时如何检查用户选择的值是否为null? 我被试了这个 但当我提交时,没有填充任何值,它就会给出输出Python 3.x 如何在python flask中检查request.form.get值是否为null?,python-3.x,flask,Python 3.x,Flask,我正在用python Flask框架启动简单的CURD操作,我想知道当用户提交表单时如何检查用户选择的值是否为null? 我被试了这个 但当我提交时,没有填充任何值,它就会给出输出 success 我也尝试了None和null,但无法工作。我尝试了您的上述方法。。它对我有效。“记住”是我html中的复选框输入类型 @app.route('/login',methods=['POST']) def login_validate(): email=request.form['email']
success
我也尝试了None和null,但无法工作。我尝试了您的上述方法。。它对我有效。“记住”是我html中的复选框输入类型
@app.route('/login',methods=['POST'])
def login_validate():
email=request.form['email']
password=request.form['pass']
remember=request.form.get('remember')
if remember:
print "present"
else:
print "not present"
Name
应为None
。很可能您正在HTML中发送空格或其他不可打印的字符。请将您的HTML表单添加到问题中。使用name
和city
的真实检查:如果不是name和not city:#…
@app.route('/login',methods=['POST'])
def login_validate():
email=request.form['email']
password=request.form['pass']
remember=request.form.get('remember')
if remember:
print "present"
else:
print "not present"