day07_python作业

day07_python作业_第1张图片
print('=========================')
print('戒网瘾学校系统')
print('1.添加学生')
print('2.查看学生')
print('3.删除学生')
print('4.退出')
print('=========================')
students=[]
while True:
    a = int(input('请输入指令:'))

    if a == 1:
        stu_names = input('学生名字為:')
        stu_ages = int(input('学生年龄为:'))
        stu_phone = input('学生电话:')
        student = {'name': stu_names, 'age': stu_ages, 'phone': stu_phone}
        students.append(student)
        print('添加成功')
        continue
    if a==2:
        b = input('请输入查看学生的名字:')
        for c in students:
            if b in c['name']:
                print('学生的名字是',c['name'],'年龄为',c['age'],'电话为',c['phone'])
            else:
                print('未找到该学生')
            continue
    if a==3:
        b=input('请输入删除学生的名字:')
        for c in students:
            if b in c['name']:
                del c['name']
                del c['age']
                del c['phone']
                print('删除成功')
                
        continue
    if a==4:
        print('退出程序')
        print('================================')
        break
    else:
        continue

你可能感兴趣的:(day07_python作业)