添加用户后报错
还请老
elif opt == "2":
while True:
os.system("cls")
print(Fore.LIGHTGREEN_EX, "\n\t1.添加用户")
print(Fore.LIGHTGREEN_EX, "\n\t2.修改用户")
print(Fore.LIGHTGREEN_EX, "\n\t3.删除用户")
print(Fore.LIGHTRED_EX, "\n\tback.返回上一层")
print(Style.RESET_ALL)
opt = input("\n\t输入操作编号:")
if opt == "back":
break
elif opt == "1":
os.system("cls")
username = input("\n\t用户名:")
password = getpass("\n\t密码:")
repassword = getpass("\n\t重复密码:")
if password != repassword:
print("\n\t两次密码不一致(3秒自动返回)")
time.sleep(3)
continue
email = input("\n\t邮箱:")
result = __role_service.search_list()
for index in range(len(result)):
one = result[index]
print(Fore.LIGHTBLUE_EX, "\n\t%d.%s" % (index + 1, one[1]))
print(Style.RESET_ALL)
opt = input("\n\t角色编号:")
role_id = result[int(opt) - 1][0]
__user_service.insert(username, password, email, role_id)
print("\n\t保存成功(3秒自动返回)")
time.sleep(3)
elif opt=="back":
break
elif opt=="exit":
sys.exit(0)
else:
print("\n\t登录失败(3秒自动返回)")
time.sleep(3)
elif opt=="2":
sys.exit(0)师指导下
16
收起
正在回答 回答被采纳积分+1
3回答
慕村8230135
2021-10-28 18:18:08
from db.mysql_db import pool class RoleDao: #查询角色列表 def search_list(self): try: con = pool.get_connection() # 获取数据库链接 cursor = con.cursor() # 创建游标 sql = "select id,role from t_role" cursor.execute(sql) result = cursor.fetchall() return result except Exception as e: print(e) finally: if "con" in dir(): con.close()
Python全能工程师
- 参与学习 人
- 提交作业 16423 份
- 解答问题 4469 个
全新版本覆盖5大热门就业方向:Web全栈、爬虫、数据分析、软件测试、人工智能,零基础进击Python全能型工程师,从大厂挑人到我挑大厂,诱人薪资在前方!
了解课程



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