我正在尝试构建用户登录系统,并且我已经成功构建了用户注册页面,但是当我尝试登录时,出现以下错误。我正在使用烧瓶、python3.6 和 pymongo。这是错误:AttributeError: 'bytes' object has no attribute 'encode'
请帮助。
Traceback(最近一次调用最后一次):文件“C:\Users\elvis\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py”,第 2309 行,调用中 返回 self.wsgi_app(environ, start_response) 文件“C:\Users\elvis\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py”,第 2295 行,在 wsgi_app response = self. handle_exception(e) 文件“C:\Users\elvis\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py”,第 1741 行,在 handle_exception reraise(exc_type, exc_value, tb) 文件中“C:\Users\elvis\AppData\Local\Programs\Python\Python36\lib\site-packages\flask_compat.py”,第 35 行,在 reraise raise 值文件“C:\Users\elvis\AppData\Local\Programs \Python\Python36\lib\site-packages\flask\app.py”,第 2292 行,在 wsgi_app 响应 = self.full_dispatch_request() 文件“C:\Users\elvis\AppData\Local\Programs\Python\Python36\lib \site-packages\flask\app.py",第 1815 行,在 full_dispatch_request rv = self.handle_user_exception(e) 文件“C:\Users\elvis\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py”,第 1718 行,在 handle_user_exception reraise(exc_type , exc_value, tb) 文件“C:\Users\elvis\AppData\Local\Programs\Python\Python36\lib\site-packages\flask_compat.py”,第 35 行,在 reraise raise value 文件“C:\Users\elvis \AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py”,第 1813 行,在 full_dispatch_request rv = self.dispatch_request() 文件“C:\Users\elvis\AppData\Local\Programs \Python\Python36\lib\site-packages\flask\app.py”,第 1799 行,在 dispatch_request 中返回 self.view_functionsrule.endpoint 文件“C:\Users\elvis\Desktop\flask apps\testmon\even\app\run .py”,第 30 行,登录 if bcrypt.hashpw(request.form['pass'].encode('utf-8'), login_user['password']) == login_user['password'].encode('utf-8'): AttributeError:“字节”对象没有属性“编码”
(错误页面截图)