【发布时间】:2021-10-21 19:45:37
【问题描述】:
我收到此代码的错误:
def login():
if request.method == 'POST':
email = request.form['email']
password = request.form['password'].encode('utf-8')
curl = mysql.connection.cursor(MySQLdb.cursors.DictCursor)
curl.execute("SELECT * FROM users WHERE email=%s",(email,))
user = curl.fetchone()
curl.close()
if len(user) > 0:
if bcrypt.hashpw(password, user["password"].encode('utf-8')) == user["password"].encode('utf-8'):
session['name'] = user['name']
session['email'] = user['email']
return redirect(url_for('home'))
else:
flash ("Error password and email not match")
return redirect(url_for('login'))
else:
flash("Error user not found")
return redirect(url_for('login'))
else:
return render_template("login.html")
错误:
TypeError: object of type 'NoneType' has no len()
当我提交不在mysql数据库中的电子邮件和密码时出现此错误,我做错了什么?
谢谢你帮助我
【问题讨论】:
-
请发布完整的回溯
标签: python python-3.x typeerror