student_dict = {} def add_student(): name = input("请输入学生姓名:") age = input("请输入学生年龄:") student_dict[name] = age print("添加成功!") def del_student(): name = input("请输入要删除的学生姓名:") if name in student_dict.keys(): del student_dict[name] print("删除成功!") else: print("该学生不存在!") def search_student(): name = input("请输入要查找的学生姓名:") if name in student_dict.keys(): print("姓名:{},年龄:{}".format(name, student_dict[name])) else: print("该学生不存在!") def display_student(): print("=== 学生信息如下 ===") for name, age in student_dict.items(): print("姓名:{},年龄:{}".format(name, age)) def main(): print("学生管理系统") while True: print("请选择操作:") print("1. 添加学生") print("2. 删除学生") print("3. 查找学生") print("4. 显示学生信息") print("5. 退出系统") choice = input("请选择(1-5):") if choice == '1': add_student() elif choice == '2': del_student() elif choice == '3': search_student() elif choice == '4': display_student() elif choice == '5': print("谢谢使用,再见!") break else: print("输入有误,请重新输入!") if __name__ == '__main__': main()