student_manage=[]
def menu():
print('=====欢迎进入学生管理系统=====\n1.添加学生\n2.查找学生\n3.删除学生\n9.退出系统'+'\n'+'='30)
global order
order=input()
def back():
print('='30+'\n1.继续\n2.返回目录'+'\n'+'='30)
order1=input()
global order
if order1=='1':
return
if order1=='2':
menu()
else:
print('请正确操作')
back()
# else:
# print('无效操作,请重新输入')
# back()
def num():
num=2012084020001
while True:
yield num
num+=1
def add_student():
global student_manage
global ge1
student ={}
name = input('输入学生姓名:')
student['姓名'] = name
age = input('输入年龄:')
student['年龄'] = age
phone = input('输入电话:')
student['电话'] = phone
student_num=next(ge1)
student['学号'] = student_num
student = {'姓名': name, '年龄': age, '电话': phone, '学号': student_num}
student_manage.append(student)
def find_student():
print('='30+'\n1.查找学生\n2.查看所有\n3.返回目录'+'\n'+'='30)
order1=input()
if order1=='1':
name=input('输入学生姓名:')
k=0
for student in student_manage:
if student.get('姓名')==name:
print(student)
k+=1
if k==0:
print('没有这个学生')
elif order1=='2':
for student in student_manage:
print(student)
elif order1=='3':
menu()
else:
print('请正确操作')
find_student()
def del_student():
print('='30+'\n1.删除学生\n2.返回目录'+'\n'+'='*30)
order1=input()
if order1=='1':
name=input('请输入学生姓名:')
k=0
for student in student_manage[:]:
if student.get('姓名')==name:
student_manage.remove(student)
print('已删除学生:'+name)
k+=1
if k==0:
print('没有这个学生')
elif order1=='2':
menu()
else:
print('请正确操作')
del_student()
order=0
ge1=num()
menu()
while order !='9':
if order=='1':
add_student()
back()
elif order=='2':
find_student()
back()
elif order=='3':
del_student()
back()
elif order=='9':
print('已退出学生管理系统')
else:
print('请正确操作')
menu()