password提示错误。

class UserDao:
def login(self,username,password):
try:
con=pool.get_connection()
cursor=con.cursor()
sql="select count(*) from t_user where username=%s and " \
"AES_DECRYPT(UNHEX(password),'helloworld')=%s"
cursor.execute(sql,(username,password))
count=cursor.fetchone()[0]
return True if count==1 else False
except Exception as e:
print(e)
finally:
if "con" in dir():
con.close()
这个直接无法进入下一层。请老师看看
正在回答
同学,你好。同学插入数据加密时使用的是"Helloworld",但在解密时使用的是"helloworld"。加密与解密时是要相对应的。


老师再看看app这个吧,看看我是哪里打错了啊
import time
from colorama import Fore,Style
from getpass import getpass
from service.user_service import UserService
from service.news_service import NewsService
import os
import sys
__user_service=UserService()
__news_service=NewsService
while True:
os.system("cls")
print(Fore.LIGHTBLUE_EX,"\n\t===================")
print(Fore.LIGHTBLUE_EX, "\n\t欢迎使用新闻管理系统")
print(Fore.LIGHTBLUE_EX, "\n\t===================")
print(Fore.LIGHTGREEN_EX,"\n\t1.登录系统")
print(Fore.LIGHTGREEN_EX,"\n\t2.退出系统")
print(Style.RESET_ALL)
opt=input("\n\t输入操作编号:")
if opt=="1":
username=input("\n\t用户名:")
password=getpass("\n\t密码:")
result=__user_service.login(username,password)
#登陆成功
if result==True:
#查询角色
role=__user_service.search_user_role(username)
os.system("cls")#清空屏幕
while True:
if role=="新闻编辑":
print("test")
elif role=="管理员":
print(Fore.LIGHTGREEN_EX,"\n\t1.新闻管理")
print(Fore.LIGHTGREEN_EX, "\n\t2.用户管理")
print(Fore.LIGHTRED_EX, "\n\tback.退出登录")
print(Fore.LIGHTRED_EX, "\n\texit.退出系统")
print(Style.RESET_ALL)
opt = input("\n\t输入操作编号:")
if opt=="1":
while True:
page=1
os.system("cls")
print(Fore.LIGHTGREEN_EX, "\n\t1.审批新闻")
print(Fore.LIGHTGREEN_EX, "\n\t2.删除新闻")
print(Fore.LIGHTRED_EX, "\n\tback.返回上一层")
print(Style.RESET_ALL)
opt = input("\n\t输入操作编号:")
if opt=="1":
page=1
while True:
os.system("cls")
count_page=__news_service.search_unreview_count_page()
result=__news_service.search_unreview_list(page)
for index in range (len(result)):
one=result[index]
print(Fore.LIGHTBLUE_EX, "\n\t%d\t%s\t%s\t%s"%(index+1,one[1],one[2],one[3]))
print(Fore.LIGHTBLUE_EX, "\n\t--------------------")
print(Fore.LIGHTBLUE_EX, "\n\t%d/%d"%(page,count_page))
print(Fore.LIGHTBLUE_EX, "\n\t--------------------")
print(Fore.LIGHTRED_EX, "\n\tback.返回上一层")
print(Fore.LIGHTRED_EX, "\n\tprev.上一页")
print(Fore.LIGHTRED_EX, "\n\tnext.下一页")
print(Style.RESET_ALL)
opt = input("\n\t输入操作编号:")
elif opt=="back":
break
elif opt=="exit":
sys.exit(0)
else:
print("\n\t登录失败(3秒自动返回)")
time.sleep(3)
elif opt=="2":
sys.exit(0)
- 参与学习 人
- 提交作业 625 份
- 解答问题 2669 个
数据库作为企业储存和管理数据的根本,掌握数据库是每个开发工程师必备的技能,本阶段带你学会用Python操作MySQL、Redis和MongoDB三大主流数据库。夯实数据库基础。
了解课程








恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星