# def show_menu(): # print('*******欢迎使用学生管理系统*************') # print('******* 1.增加学生信息************') # print('******* 2.删除学生信息************') # print('******* 3.修改学生信息************') # print('******* 4.展示所有学生信息************') # print('******* 5.根据名字查询************') # print('******* 6.统计平均年龄************') # print('******* 7.退出系统************') # # def add_stu(): # flag = "y" # student =[] # while flag == "y": # id = input("请输入编号:") # name = input("请输入名字") # sex = input("请输入性别") # age = input("请输入年龄") # # stu = {"id":id,"name":name,"sex":sex,"age":age} # student.append(stu) # flag= input("是否继续(y/n):") # print("学生添加完成") # return student # def del_stu(student): #删除 # print(student) # name = input("请输入要删除的名字:") # delnum = 0 # for i,stu in enumerate(student): # if stu["name"] == name: # delnum=i # break # student.pop(delnum) # # def update_stu(student): # 修改 # print(student) # name = input("请输入要修改的名字") # delnum = 0 # for i, stu in enumerate(student): # if stu['name'] == name: # delnum = i # break # student.pop(delnum) # # id = input("请输入编号:") # name = input("请输入名字") # sex = input("请输入性别") # age = input("请输入年龄") # stu = {"id": id, "name": name, "sex": sex, "age": age} # return student.append(stu) # # # # def show_stu(student): # 展示 # for stu in student: # print(stu) # # # # def search_name(student): # 查找 # print(student) # name = input("请输入查找的名字") # delunm = 0 # for i,stu in enumerate(student): # if stu["name"] == name: # delnum=i # break # print(student[delunm]) # # def avg_age(student): # 统计年龄 # sum = 0 # for stu in student: # sum += int(stu["age"]) # print(f"平均年龄:{sum/len(student)}") # # if __name__ =="__main__": # student=[] # while True: # show_menu() # option =int(input("请输入你要做的选项(1-7):")) # if option == 7: # print("感谢使用") # flag = input("确定要退出吗?(y退出/n不退出):") # if flag == "y": # break # else: # continue # elif option==1: # student = add_stu() # continue # elif option == 2: # del_stu(student) # elif option ==3: # update_stu(student) # elif option == 4: # show_stu(student) # elif option ==5: # search_name(student) # elif option == 6: # avg_age(student) # else: # print("输入有误,请重新输入")