-
Notifications
You must be signed in to change notification settings - Fork 0
/
StudentManageSystem.py
101 lines (86 loc) · 2.72 KB
/
StudentManageSystem.py
1
students_info = []# 添加学生def add_user(): """ 添加学生 """ s_id = input("请输入学号:") s_name = input("请输入姓名:") s_tel = input("请输入手机号:") global students_info student_info = {'id': s_id, 'name': s_name, 'tel': s_tel} for student in students_info: if student['id'] == s_id: print(f"学号{s_id}重复,请核对后,在输入!") break elif student['name'] == s_name: print(f"名字{s_name}重复,请核对后,在输入!") break students_info.append(student_info) print(students_info)# 查询学生def query_user(): s_name = input("请输入姓名:") global students_info for student in students_info: if student['name'] == s_name: print(f"查询到学员为:{student}") break else: print("-"*10+"学员不存在!"+"-"*10)# 删除学生def del_user(): s_id = input("请输入学号:") s_name = input("请输入姓名:") global students_info for student in students_info: if student['id'] == s_id: students_info.remove(student) print(f"成功删除{s_id}") break elif student['name'] == s_name: students_info.remove(student) print(f"成功删除{s_name}") break else: print("-"*10+"学员不存在!"+"-"*10) print(students_info)# 修改学生def modify_user(): s_name = input("请输入姓名:") global students_info for stu in students_info: if stu['name'] == s_name: stu['tel'] = input("请输入手机号:") print(f"修改后的学员信息为:{stu}") break else: print("-"*10+"学员不存在!"+"-"*10) print(students_info)while True: func = {'1': '添加学员', '2': '修改学员', '3': "删除学员", '4': "查询学员", '5': "退出系统"} print(func) func_index = int(input("请选择功能:")) if func_index == 1: add_user() elif func_index == 2: modify_user() elif func_index == 3: del_user() elif func_index == 4: query_user() elif func_index == 6: # 退出系统 exit_str = input("确定要退出么?是 or 否 :") if exit_str == "是": print("成功退出!") break elif exit_str == "y": print("成功退出!") break elif exit_str == "Y": print("成功退出!") break elif exit_str == "YES": print("成功退出!") break elif exit_str == "yes": print("成功退出!") break