students = []
num = 0
while num != 'q':
print('欢迎进入学生管理系统')
print('1.添加学生')
print('2.查找学生')
print('3.删除学生')
print('q.退出系统')
num = input('>>>')
while num == '1':
temp = []
name = input('请输入学生姓名:')
age = int(input('请输入学生年龄:'))
tel = int(input('请输入学生电话号码:'))
temp.append(name)
temp.append(age)
temp.append(tel)
students.append(temp)
print('1.继续添加学生')
print('2.返回上一层')
num1 = int(input('>>>'))
if num1 == 2 or num1 != 1:
num = '9'
while num == '2':
print('1.查看所有学生信息')
print('2.根据名字查看学生信息')
print('3.返回上一层')
num1 = int(input('>>>'))
if num1 == 1:
for x in range(len(students)):
print('name:%s age:%d tel:%d' % (students[x][0],students[x][1],students[x][2]))
elif num1 == 2:
name = input('请输入要查看的学生姓名:')
for x in range(len(students)):
if name == students[x][0]:
print('name:%s age:%d tel:%d' % (students[x][0], students[x][1], students[x][2]))
elif num1 == 3 or num1 != 1 or num1 != 2:
num = '9'
while num == '3':
name = input('请输入要删除的学生姓名:')
label = True
for x in range(len(students)):
if name == students[x][0]:
label = False
print(x,'name:%s age:%d tel:%d' % (students[x][0],students[x][1],students[x][2]))
if label:
print('输入姓名错误!')
print('1.继续删除')
print('2.返回上一层')
num1 = int(input('>>>'))
if num1 == 1:
continue
if num1 == 2 or num1 != 1:
num = '9'
index = int(input('请输入要删除学生的下标:'))
del students[index]
print('删除成功!')
print('1.继续删除')
print('2.返回上一层')
num1 = int(input('>>>'))
if num1 == 2 or num1 != 1:
num = '9'
print(students)
网友评论