当前位置:   article > 正文

python学生管理系统报告,python学生管理系统总结_python学生管理系统部署说明书

python学生管理系统部署说明书

大家好,本文将围绕python编写学生管理系统,用gui做ui展开说明,python学生管理系统部署说明书是一个很多人都想弄明白的事情,想搞清楚python学生管理系统设计报告需要先了解以下几个事情。

目录

一、运行结果:

数据库操作:

程序运行:

二、源码如下:

database.py: 

project.py:


一、运行结果:

数据库操作可以看以下链接:

在命令窗口使用sql语句操作Mysql数据库_sql命令窗口怎么执行命令_敬往事一杯酒哈的博客-CSDN博客

数据库操作:

图1:数据库中的表数据

程序运行:

图1:首页界面

图2:成绩管理系统功能界面

                                                        图3:添加功能

图4:统计某课程在班级的成绩分布情况

图5:按学号查询

图6:修改学生信息界面

二、源码如下:

database.py: 

  1. import pymysql
  2. import pandas as pd
  3. class DataBase:
  4. # 定义连接数据库对象和游标对象
  5. db = None
  6. cursor = None
  7. # 连接数据库
  8. def connectDatabases(self, user, password):
  9. try:
  10. self.db = pymysql.Connect(
  11. user=user,
  12. password=password,
  13. host="localhost",
  14. database="Student_Management_System",
  15. port=3306,
  16. charset="utf8"
  17. )
  18. self.cursor = self.db.cursor()
  19. return True
  20. except:
  21. return False
  22. # 添加学生信息
  23. def addStudent(self, user, password, id, major, className, name, chinese, math, english, average_score,
  24. total_score):
  25. self.connectDatabases(self, user, password)
  26. sql = "insert into students values(%s,%s,%s,%s,%s,%s,%s,%s,%s)"
  27. add_data = [id, name, chinese, math, english, average_score, total_score, major, className]
  28. try:
  29. self.cursor.execute(sql, add_data)
  30. self.db.commit()
  31. except:
  32. self.db.rollback()
  33. finally:
  34. self.cursor.close()
  35. self.db.close()
  36. # 删除学生信息
  37. def deleteStudent(self, user, password, id):
  38. self.connectDatabases(self, user, password)
  39. sql = "delete from students where id=%s"
  40. del_data = [id]
  41. try:
  42. self.cursor.execute(sql, del_data)
  43. self.db.commit()
  44. except:
  45. self.db.rollback()
  46. finally:
  47. self.cursor.close()
  48. self.db.close()
  49. # 查询指定学生信息
  50. def checkStudent(self, user, password, id):
  51. self.connectDatabases(self, user, password)
  52. sql = "select * from students where id=%s"
  53. sel_data = id
  54. try:
  55. self.cursor.execute(sql, sel_data)
  56. result = self.cursor.fetchone()
  57. print("学号:%s 专业:%s 班级:%s 姓名:%s 语文:%s 数学:%s 英语:%s 平均分:%s 总分:%s" % (
  58. result[0], result[7], result[8], result[1], result[2], result[3], result[4], result[5], result[6]))
  59. return result[0], result[1], result[2], result[3], result[4], result[5], result[6], result[7], result[8]
  60. except:
  61. self.db.rollback()
  62. finally:
  63. self.cursor.close()
  64. self.db.close()
  65. # 修改学生信息,学号不可修改
  66. def modifyStudent(self, user, password, id, name, chinese, math, english, average_score, total_score):
  67. self.connectDatabases(self, user, password)
  68. sql = "update students set name=%s,chinese=%s,math=%s,english=%s,average_score=%s,total_score=%s where id=%s"
  69. mod_data = [name, chinese, math, english, average_score, total_score, id]
  70. try:
  71. self.cursor.execute(sql, mod_data)
  72. self.db.commit()
  73. except:
  74. self.db.rollback()
  75. finally:
  76. self.cursor.close()
  77. self.db.close()
  78. # 判断学号是否存在
  79. def judgeStudent(self, user, password, id):
  80. self.connectDatabases(self, user, password)
  81. sql = "select * from students where id = %s"
  82. sel_data = id
  83. try:
  84. self.cursor.execute(sql, sel_data)
  85. row = self.cursor.fetchone()
  86. if row is not None:
  87. return True
  88. except:
  89. self.db.rollback()
  90. return False
  91. finally:
  92. self.cursor.close()
  93. self.db.close()
  94. # 统计学生成绩的人数:
  95. def countScores(self, user, password, className, course):
  96. self.connectDatabases(self, user, password)
  97. sql = "SELECT {} FROM students WHERE class = %s".format(course)
  98. try:
  99. self.cursor.execute(sql, (className,))
  100. scores = self.cursor.fetchall()
  101. if len(scores) == 0:
  102. print("系统中没有学生信息,请先添加!")
  103. else:
  104. score_ranges = {
  105. "0~59": 0,
  106. "60~79": 0,
  107. "80~89": 0,
  108. "90~100": 0
  109. }
  110. for score_tuple in scores:
  111. score = score_tuple[0] # 获取元组中的第一个元素
  112. if 0 <= score <= 59:
  113. score_ranges["0~59"] += 1
  114. elif 60 <= score <= 79:
  115. score_ranges["60~79"] += 1
  116. elif 80 <= score <= 89:
  117. score_ranges["80~89"] += 1
  118. elif 90 <= score <= 100:
  119. score_ranges["90~100"] += 1
  120. print("课程:{} 班级:{}".format(course, className))
  121. for range_name, count in score_ranges.items():
  122. print("{} 分数范围的学生人数:{}".format(range_name, count))
  123. except Exception as e:
  124. print(e)
  125. self.db.rollback()
  126. self.db.close()
  127. def sortScore(self, user, password, className, flag):
  128. self.connectDatabases(self, user, password)
  129. sql = "select * from students where class=%s"
  130. try:
  131. self.cursor.execute(sql, (className,))
  132. students = self.cursor.fetchall()
  133. if len(students) == 0:
  134. print("系统中没有学生信息,请先添加!")
  135. else:
  136. students_list = []
  137. for row in students:
  138. student_info = {
  139. "学号": row[0],
  140. "专业": row[7],
  141. "班级": row[8],
  142. "姓名": row[1],
  143. "语文": row[2],
  144. "数学": row[3],
  145. "英语": row[4],
  146. "平均分": row[5],
  147. "总分": row[6]
  148. }
  149. students_list.append(student_info)
  150. if flag == '1':
  151. students_list.sort(key=lambda k: (k.get("平均分")), reverse=True)
  152. elif flag == '2':
  153. students_list.sort(key=lambda k: (k.get("语文")), reverse=True)
  154. elif flag == '3':
  155. students_list.sort(key=lambda k: (k.get("数学")), reverse=True)
  156. elif flag == '4':
  157. students_list.sort(key=lambda k: (k.get("英语")), reverse=True)
  158. # 排序
  159. for student in students_list:
  160. print("学号:%s 专业:%s 班级:%s 姓名:%s 语文:%s 数学:%s 英语:%s 平均分:%s 总分:%s" % (
  161. student["学号"], student["专业"], student["班级"], student["姓名"], student["语文"], student["数学"],
  162. student["英语"], student["平均分"], student["总分"]
  163. ))
  164. choice = input("是否存入excel表?是:1 否:0")
  165. if choice == '1':
  166. df = pd.DataFrame(students_list)
  167. fileName = input("请输入excel文件名:")
  168. excel_file = fileName + '.xlsx'
  169. df.to_excel(excel_file, index=False)
  170. print(f"学生信息已导出到 {excel_file}")
  171. else:
  172. print("没有导入excel")
  173. except:
  174. self.db.rollback()
  175. self.db.close()
  176. def statisticsScore(self, user, password, className):
  177. self.connectDatabases(self, user, password)
  178. sql = "SELECT * FROM students WHERE class = %s"
  179. try:
  180. self.cursor.execute(sql, (className,))
  181. students = self.cursor.fetchall()
  182. if len(students) == 0:
  183. print("系统中没有学生信息,请先添加!")
  184. else:
  185. students_list = []
  186. for row in students:
  187. student_info = {
  188. "学号": row[0],
  189. "专业": row[7],
  190. "班级": row[8],
  191. "姓名": row[1],
  192. "语文": row[2],
  193. "数学": row[3],
  194. "英语": row[4],
  195. "平均分": row[5],
  196. "总分": row[6]
  197. }
  198. average_score = student_info["平均分"]
  199. if average_score >= 80:
  200. students_list.append(student_info)
  201. print(students_list)
  202. except Exception as e:
  203. print(e)
  204. self.db.rollback()
  205. self.db.close()
  206. # 输出学生信息
  207. def showStudentInformation(self, user, password):
  208. self.connectDatabases(self, user, password)
  209. sql = "select * from students"
  210. try:
  211. self.cursor.execute(sql)
  212. students = self.cursor.fetchall()
  213. if len(students) == 0:
  214. print("系统中没有学生信息,请先添加!")
  215. else:
  216. students_list = []
  217. for row in students:
  218. student_info = {
  219. "学号": row[0],
  220. "专业": row[7],
  221. "班级": row[8],
  222. "姓名": row[1],
  223. "语文": row[2],
  224. "数学": row[3],
  225. "英语": row[4],
  226. "平均分": row[5],
  227. "总分": row[6]
  228. }
  229. print("学号:%s 专业:%s 班级:%s 姓名:%s 语文:%s 数学:%s 英语:%s 平均分:%s 总分:%s" % (
  230. row[0], row[7], row[8], row[1], row[2], row[3], row[4], row[5], row[6]))
  231. students_list.append(student_info)
  232. # students_list.sort(key=lambda k: (k.get('平均分')))
  233. # print(students_list)
  234. except:
  235. self.db.rollback()
  236. self.db.close()
  237. # 另存学生信息
  238. def saveStudent(self, user, password):
  239. self.connectDatabases(self, user, password)
  240. sql = "select * from students"
  241. try:
  242. self.cursor.execute(sql)
  243. result = self.cursor.fetchall()
  244. if len(result) == 0:
  245. print("系统中没有学生信息,请先添加!")
  246. else:
  247. file = open("学生信息.txt", "a")
  248. for row in result:
  249. file.write("学号:%s\t姓名:%s\t语文:%s\t数学:%s\t英语:%s\t平均分:%s\t总分:%s\n" % (
  250. row[0], row[1], row[2], row[3], row[4], row[5], row[6]))
  251. except:
  252. self.db.rollback()
  253. finally:
  254. self.cursor.close()
  255. self.db.close()
  256. file.close()
  257. # 将excel导入数据库:
  258. def importScoresFromExcel(self, user, password, excel_file):
  259. self.connectDatabases(user, password)
  260. try:
  261. df = pd.read_excel(excel_file)
  262. if "学号" not in df.columns or "姓名" not in df.columns or "班级" not in df.columns or "专业" not in df.columns or "语文" not in df.columns or "数学" not in df.columns or "英语" not in df.columns:
  263. print("Excel表格格式不正确,请确保包含学号、姓名、班级、专业、语文、数学和英语列")
  264. else:
  265. for _, row in df.iterrows():
  266. student_info = {
  267. "学号": row["学号"],
  268. "姓名": row["姓名"],
  269. "班级": row["班级"],
  270. "专业": row["专业"],
  271. "语文": row["语文"],
  272. "数学": row["数学"],
  273. "英语": row["英语"],
  274. "平均分": (row["语文"] + row["数学"] + row["英语"]) / 3,
  275. "总分": row["语文"] + row["数学"] + row["英语"],
  276. }
  277. sql = "INSERT INTO students (学号, 姓名, 班级, 专业, 语文, 数学, 英语, 平均分, 总分) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)"
  278. self.cursor.execute(sql, (
  279. student_info["学号"], student_info["姓名"], student_info["班级"], student_info["专业"],
  280. student_info["语文"], student_info["数学"], student_info["英语"],
  281. student_info["平均分"], student_info["总分"]
  282. ))
  283. self.db.commit()
  284. print("成绩导入成功!")
  285. except Exception as e:
  286. print("成绩导入失败:", str(e))
  287. self.db.rollback()
  288. self.db.close()

project.py:

  1. from database import DataBase
  2. import colorama
  3. import datetime
  4. # 初始化
  5. colorama.init()
  6. # 获取当前时间
  7. def getTime():
  8. current_time = datetime.datetime.now()
  9. current_date = current_time.strftime("%Y-%m-%d")
  10. current_time = current_time.strftime("%H:%M:%S")
  11. print(colorama.Fore.GREEN + "当前日期: " + current_date)
  12. print(colorama.Fore.GREEN + "当前时间: " + current_time)
  13. class Student(object):
  14. # 定义用户名和密码
  15. user = None
  16. password = None
  17. # 添加学生信息
  18. def addStudent(self):
  19. print(colorama.Fore.GREEN + "##########################################################################################")
  20. print(colorama.Fore.GREEN + "▓ * 欢迎进入添加学生的界面 * ▓")
  21. print(colorama.Fore.GREEN + "##########################################################################################")
  22. student_number = int(input(colorama.Fore.GREEN + "请输入添加的学生人数:"))
  23. for i in range(student_number):
  24. sno = input(colorama.Fore.GREEN + "请输入学号:")
  25. if not DataBase.judgeStudent(DataBase, self.user, self.password, sno):
  26. major = input(colorama.Fore.GREEN + "请输入专业:")
  27. clas = input(colorama.Fore.GREEN + "请输入班级:")
  28. sname = input(colorama.Fore.GREEN + "请输入姓名:")
  29. chinese = int(input(colorama.Fore.GREEN + "请输入语文成绩:"))
  30. math = int(input(colorama.Fore.GREEN + "请输入数学成绩:"))
  31. english = int(input(colorama.Fore.GREEN + "请输入英语成绩:"))
  32. average_score = (chinese + math + english) / 3
  33. total_score = chinese + math + english
  34. DataBase.addStudent(DataBase, self.user, self.password, sno, major, clas, sname, chinese, math,
  35. english, average_score, total_score)
  36. print(colorama.Fore.GREEN + "成功添加学号为【%s】的学生!" % sno)
  37. else:
  38. print(colorama.Fore.GREEN + "系统已存在学号为【%s】的学生信息,请勿重复添加!" % sno)
  39. print(colorama.Fore.GREEN + "##########################################################################################")
  40. print(colorama.Fore.GREEN + "▓ ▓")
  41. print(colorama.Fore.GREEN + "##########################################################################################")
  42. # 删除学生信息
  43. def deleteStudent(self):
  44. print(colorama.Fore.GREEN + "##########################################################################################")
  45. print(colorama.Fore.GREEN + "▓ * 欢迎进入删除学生的界面 * ▓")
  46. print(colorama.Fore.GREEN + "##########################################################################################")
  47. sno = input(colorama.Fore.GREEN + "请输入需要删除的学生学号:")
  48. if DataBase.judgeStudent(DataBase, self.user, self.password, sno):
  49. DataBase.deleteStudent(DataBase, self.user, self.password, sno)
  50. print(colorama.Fore.GREEN + "成功删除学号为【%s】的学生!" % sno)
  51. else:
  52. print(colorama.Fore.GREEN + "系统中不存在学号为【%s】的学生,无法删除!" % sno)
  53. print(colorama.Fore.GREEN + "##########################################################################################")
  54. print(colorama.Fore.GREEN + "▓ ▓")
  55. print(colorama.Fore.GREEN + "##########################################################################################")
  56. # 实现修改学生信息时,用户不输入则学生属性不发生改变的功能
  57. def user_input(self, message, info):
  58. s = input(message)
  59. if s == "":
  60. return info
  61. else:
  62. return s
  63. # 修改学生信息,学号不可修改
  64. def modifyStudent(self):
  65. print(colorama.Fore.GREEN + "##########################################################################################")
  66. print(colorama.Fore.GREEN + "▓ * 欢迎进入修改学生信息的界面 * ▓")
  67. print(colorama.Fore.GREEN + "##########################################################################################")
  68. sno = input(colorama.Fore.GREEN + "请输入需要修改的学生学号:")
  69. if DataBase.judgeStudent(DataBase, self.user, self.password, sno):
  70. sno, sname, chinese, math, english, average_score, total_score, major, clas = DataBase.checkStudent(
  71. DataBase, self.user, self.password, sno)
  72. sname = self.user_input(colorama.Fore.GREEN + "请输入学生的姓名:【回车不修改】", sname)
  73. major = self.user_input(colorama.Fore.GREEN + "请输入学生的专业:【回车不修改】", major)
  74. clas = self.user_input(colorama.Fore.GREEN + "请输入学生的班级:【回车不修改】", clas)
  75. chinese = int(self.user_input(colorama.Fore.GREEN + "请输入学生语文成绩:【回车不修改】", chinese))
  76. math = int(self.user_input(colorama.Fore.GREEN + "请输入学生数学成绩:【回车不修改】", math))
  77. english = int(self.user_input(colorama.Fore.GREEN + "请输入学生英语成绩:【回车不修改】", english))
  78. average_score = (chinese + math + english) / 3
  79. total_score = chinese + math + english
  80. DataBase.modifyStudent(DataBase, self.user, self.password, sno, sname, chinese, math, english,
  81. average_score, total_score)
  82. print(colorama.Fore.GREEN + "成功修改学号为【%s】的学生信息!" % sno)
  83. else:
  84. print(colorama.Fore.GREEN + "系统中不存在学号为【%s】的学生,无法修改!" % sno)
  85. print(colorama.Fore.GREEN + "##########################################################################################")
  86. print(colorama.Fore.GREEN + "▓ ▓")
  87. print(colorama.Fore.GREEN + "##########################################################################################")
  88. # 查询学生信息
  89. def checkStudent(self):
  90. print(colorama.Fore.GREEN + "#######################################################################################################")
  91. print(colorama.Fore.GREEN + "▓ * 欢迎进入查询学生信息的界面 * ▓")
  92. print(colorama.Fore.GREEN + "#######################################################################################################")
  93. id = input(colorama.Fore.GREEN + "请输入需要查询的学生学号:")
  94. if DataBase.judgeStudent(DataBase, self.user, self.password, id):
  95. DataBase.checkStudent(DataBase, self.user, self.password, id)
  96. else:
  97. print(colorama.Fore.GREEN + "系统中不存在学号为【%s】的学生!" % id)
  98. print(colorama.Fore.GREEN + "########################################################################################################")
  99. print(colorama.Fore.GREEN + "▓ ▓")
  100. print(colorama.Fore.GREEN + "########################################################################################################")
  101. # 输出学生信息
  102. def showStudentsInformation(self):
  103. print(colorama.Fore.GREEN + "#####################################################################################################")
  104. print(colorama.Fore.GREEN + "▓ * 所有学生信息的界面 * ▓")
  105. print(colorama.Fore.GREEN + "#####################################################################################################")
  106. DataBase.showStudentInformation(DataBase, self.user, self.password)
  107. print(colorama.Fore.GREEN + "####################################################################################################")
  108. print(colorama.Fore.GREEN + "▓ ▓")
  109. print(colorama.Fore.GREEN + "####################################################################################################")
  110. # 保存学生信息
  111. def saveStudent(self):
  112. DataBase.saveStudent(DataBase, self.user, self.password)
  113. print(colorama.Fore.GREEN + "保存成功!")
  114. def sortScore(self):
  115. print(
  116. colorama.Fore.GREEN + "##########################################################################################")
  117. print(colorama.Fore.GREEN + "▓ * 欢迎进入学生成绩排序功能 * ▓")
  118. print(
  119. colorama.Fore.GREEN + "##########################################################################################")
  120. className = input("请输入需要查找的班级排名:")
  121. flag = input("请选择排列规则:按(1:平均分 2:语文 3:数学 4:英语)从大到小")
  122. DataBase.sortScore(DataBase, self.user, self.password, className, flag)
  123. print(
  124. colorama.Fore.GREEN + "##########################################################################################")
  125. print(
  126. colorama.Fore.GREEN + "▓ ▓")
  127. print(
  128. colorama.Fore.GREEN + "##########################################################################################")
  129. def countScores(self):
  130. print(colorama.Fore.GREEN + "##########################################################################################")
  131. print(colorama.Fore.GREEN + "▓ * 欢迎进入学生统计学生考试成绩分布界面 * ▓")
  132. print(colorama.Fore.GREEN + "##########################################################################################")
  133. className = input("请输入需要统计的班级:")
  134. course = input("请输入课程名称:")
  135. DataBase.countScores(DataBase, self.user, self.password, className, course)
  136. print(
  137. colorama.Fore.GREEN + "##########################################################################################")
  138. print(
  139. colorama.Fore.GREEN + "▓ ▓")
  140. print(
  141. colorama.Fore.GREEN + "##########################################################################################")
  142. def statisticsScore(self):
  143. print(
  144. colorama.Fore.GREEN + "##########################################################################################")
  145. print(colorama.Fore.GREEN + "▓ * 欢迎进入学生统计学生考试成绩对于80分界面 * ▓")
  146. print(colorama.Fore.GREEN + "##########################################################################################")
  147. className = input("请输入需要统计的班级:")
  148. DataBase.statisticsScore(DataBase, self.user, self.password, className)
  149. print(
  150. colorama.Fore.GREEN + "##########################################################################################")
  151. print(
  152. colorama.Fore.GREEN + "▓ ▓")
  153. print(
  154. colorama.Fore.GREEN + "##########################################################################################")
  155. # 功能菜单打印
  156. @staticmethod
  157. def menu(self):
  158. # os.system('cls')
  159. getTime()
  160. print(
  161. colorama.Fore.GREEN + "##########################################################################################")
  162. print(colorama.Fore.GREEN + "▓ * 欢迎进入学生成绩管理系统 * ▓")
  163. print(
  164. colorama.Fore.GREEN + "##########################################################################################")
  165. print(colorama.Fore.GREEN + " ◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆")
  166. print(colorama.Fore.GREEN + " |◆|******|◆| |◆|******|◆|")
  167. print(colorama.Fore.GREEN + " |◆|******|◆| ☆ 退出系统 请按 0 |◆|******|◆|")
  168. print(colorama.Fore.GREEN + " |◆|******|◆| ☆ 添加学生 请按 1 |◆|******|◆|")
  169. print(colorama.Fore.GREEN + " |◆|******|◆| ☆ 输出学生 请按 2 |◆|******|◆|")
  170. print(colorama.Fore.GREEN + " |◆|******|◆| ☆ 删除学生 请按 3 |◆|******|◆|")
  171. print(colorama.Fore.GREEN + " |◆|******|◆| ☆ 查询学生 请按 4 |◆|******|◆|")
  172. print(colorama.Fore.GREEN + " |◆|******|◆| ☆ 修改学生 请按 5 |◆|******|◆|")
  173. print(colorama.Fore.GREEN + " |◆|******|◆| ☆ 另存学生 请按 6 |◆|******|◆|")
  174. print(colorama.Fore.GREEN + " |◆|******|◆| ☆ 排序成绩 请按 7 |◆|******|◆|")
  175. print(colorama.Fore.GREEN + " |◆|******|◆| ☆ 统计成绩 请按 8 |◆|******|◆|")
  176. print(colorama.Fore.GREEN + " |◆|******|◆| |◆|******|◆|")
  177. print(colorama.Fore.GREEN + " ◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆")
  178. print(
  179. colorama.Fore.GREEN + "##########################################################################################")
  180. print(
  181. colorama.Fore.GREEN + "▓ ▓")
  182. print(
  183. colorama.Fore.GREEN + "##########################################################################################")
  184. choice = input(colorama.Fore.GREEN + "请输入功能前面的代码:")
  185. if choice == "1":
  186. self.addStudent()
  187. elif choice == "2":
  188. self.showStudentsInformation()
  189. elif choice == "3":
  190. self.deleteStudent()
  191. elif choice == "4":
  192. self.checkStudent()
  193. elif choice == "5":
  194. self.modifyStudent()
  195. elif choice == "6":
  196. self.saveStudent()
  197. elif choice == "7":
  198. self.sortScore()
  199. elif choice == "8":
  200. self.countScores()
  201. elif choice == "9":
  202. self.statisticsScore()
  203. elif choice == "0":
  204. print(colorama.Fore.GREEN + "感谢使用,欢迎下次登陆!")
  205. exit()
  206. else:
  207. print(colorama.Fore.GREEN + "您输入的序号不对,请重新输入!")
  208. # 登录界面
  209. def main_menu(self):
  210. getTime()
  211. print(colorama.Fore.GREEN + "##########################################################################################")
  212. print(colorama.Fore.GREEN + "▓ * 欢迎进入学生成绩管理系统 * ▓")
  213. print(colorama.Fore.GREEN + "##########################################################################################")
  214. print(colorama.Fore.GREEN + " ◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆")
  215. print(colorama.Fore.GREEN + " |◆|******|◆| |◆|******|◆|")
  216. print(colorama.Fore.GREEN + " |◆|******|◆| ☆ 退出 请按 0 |◆|******|◆|")
  217. print(colorama.Fore.GREEN + " |◆|******|◆| ☆ 登录 请按 1 |◆|******|◆|")
  218. print(colorama.Fore.GREEN + " |◆|******|◆| |◆|******|◆|")
  219. print(colorama.Fore.GREEN + " ◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆")
  220. print(colorama.Fore.GREEN + "##########################################################################################")
  221. print(colorama.Fore.GREEN + "▓ ▓")
  222. print(colorama.Fore.GREEN + "##########################################################################################")
  223. # 程序调用
  224. def run(self):
  225. while True:
  226. self.main_menu()
  227. choice = input(colorama.Fore.GREEN + "请输入您的选择:")
  228. if choice == "1":
  229. self.user = input(colorama.Fore.GREEN + "请输入您的用户名:")
  230. self.password = input(colorama.Fore.GREEN + "请输入您的密码:")
  231. if DataBase.connectDatabases(DataBase, self.user, self.password):
  232. # print(colorama.Fore.GREEN+"登陆成功!!!")
  233. while True:
  234. self.menu(self)
  235. else:
  236. print(colorama.Fore.GREEN + "用户名或密码错误,请重新输入!")
  237. else:
  238. exit()
  239. if __name__ == "__main__":
  240. s = Student()
  241. s.run()

文章知识点与官方知识档案匹配,可进一步学习相关知识
Java技能树首页概览147781 人正在系统学习中
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/运维做开发/article/detail/769012
推荐阅读
相关标签
  

闽ICP备14008679号