stu1={"name":"张三","age":4,"gender":"男","height":178}
stu2={"name":"小明","age":4,"gender":"女","height":168}
stu3={"name":"李四","age":4,"gender":"男","height":148}
stu4={"name":"王五","age":4,"gender":"男","height":158}
students = [stu1,stu2,stu3,stu4]
while True:
print("\n\n---------欢迎登陆学生系统---------")
print("1.增加学生\n2.删除学生\n3.修改学生\n4.查找学生\n5.退出程序")
num = int(input("请输入你的编号"))
if num ==1:
name=input("请输入名字")
age=int(input("请输入年纪"))
gender=input("请输入性别")
height=int(input("请输入身高"))
stu5={"name":name,"age":age,"gender":gender,"height":height}
students.append(stu5)
for stu in students:
print("------------")
for key,value in stu.items():
print(key,value)
elif num == 2:
print ("1.按照序号删除\n2.全部删除")
choose = int(input("请选择你的操作"))
if choose ==1:
stu_number =int(input("请选择要删除学生编号"))
students:pop(stu_number-1)
print("该学生已经被删除")
for stu in students:
print("----------")
for key,value in stu.items():
print(key,value)
elif choose == 2:
yes_no=input("确定要执行改操作吗?yes/no")
if yes_no == "yes":
print("____________")
print("学生数据已经清除")
students.clear()
elif num ==3:
print("当前有"+str(len(students))+"个学生")
stu_number = int (input("请输入要修改学生的编号"))
students.pop(stu_number-1)
name=input("请输入更改名字")
age=int(input("请输更改入年纪"))
gender=input("请输更改入性别")
height=int(input("请输入更改身高"))
stu5={"name":name,"age":age,"gender":gender,"height":height}
students.insert(stu_number-1,stu5)
for stu in students:
print("----------")
for key,value in stu.items():
print(key,value)
elif num == 4:
print ("当前有"+str(len(students))+"个学生")
for stu in students:
print("-----------")
for key,value in stu.items():
print (key,value)
elif num == 5:
yes_no = input("您确定要退出吗?yes_no")
if yes_no == "yes":
print("您已经退出系统")
break
else:
print("您输入的要错误,请重新输入")