本人小白,求大佬解答程序为什么会报错
print("欢迎来到学生管理系统!")
students=[]
def add_student():
print("请输入学生信息")
num=input("请输入学生学号:")
name=input("请输入学生姓名:")
age=input("请输入学生年龄;")
grade=input("请输入学生的班级:")
student={"num":num,"name":name,"age":age,"grade":grade}
students.append(student)
print("添加成功!")
def list_student():
print("以下为所有学生信息")
for i in students:
num=i['num']
name=i['name']
age=i['age']
grade=i['grade']
print("学号:%s,姓名:%s,年龄:%s,班级;%s"%(num,name,age,grade))
def find_student():
num=input("请输入学号:")
for i in students:
if i[num]==num:
num=i['num']
name=i['name']
age=i['age']
grade=i['grade']
print("学号:%s,姓名:%s,年龄:%s,班级;%s"%(num,name,age,grade))
else:
print("输入错误请重新输入")
continue
def delete_student():
num=input("请输入你要删除学生的学号:")
for i in students:
if i[num]==num:
num=i['num']
name=i['name']
age=i['age']
grade=i['grade']
print("学号:%s,姓名:%s,年龄:%s,班级;%s"%(num,name,age,grade))
a=input("是否要删除")
if a=="是":
students.pop('num','name','age','grade')
else:
break
else:
print("输入错误,请重新输入")
continue
def main():
while True:
print("="*20)
print("1.新增学生信息")
print("2.列出所有学生信息")
print("3.查找学生信息")
print("4.删除学生信息")
print("="*20)
number=input("请输入你要操作的序号:")
if not number.isdigit() or number not in ['1','2','3','4']:
print("序号输入不正确!")
continue
else:
if number=='1':
add_student()
elif number=='2':
list_student()
elif number=='3':
find_student()
else:
delete_student()
if __name__=='__main__':
main()