美文网首页
学生管理系统简洁版

学生管理系统简洁版

作者: 憨猜猜 | 来源:发表于2019-01-07 21:07 被阅读0次
# def page():
while True:
    print('''/
    =======================================================
    ❀❀欢迎hezhicheng:
    
           💗 1.   添加学生
           💗 2.   查看学生
           💗 3.   修改学生信息
           💗 4.   删除学生
           💗 5.   返回
    =======================================================
    ''')


# page()
    select = input('请选择(1-5):')
    students = []


    def new_id():
        """学号"""
        num = 1
        while True:
            yield 'python1809' + str(num)
            num += 1


    shi_id = new_id()
    # print(next(shi_id))


    # def add_the_student():
    #     """添加学生"""
    if select == '1':
        while True:
            name = input('请输入学生姓名:')
            age = input('请输入年龄:')
            tel = input('请输入学生电话:')
            stu = shi_id
            dict1 = {'stu': stu, 'name': name, 'age': age, 'tel': tel}
            students.append(dict1)
            print('''
            添加成功!
            1.继续
            2.返回           
            ''')
            select1 = input('请选择(1-2):')
            if select1 != '1':
                break


# print(add_the_student())


# def look_at_the_students():
#     """查看学生"""
    elif select == '2':
        while True:
            # print(students)
            print('''
            1.查看所有学生
            2.按姓名查找
            3.按学号查找
            4.返回
            ''')
            select2 = input('请选择(1-4):')
            if select2 == '1':
                print(students)
            elif select2 == '2':
                import_name = input('请输入姓名:')
                for dict1 in students:
                    if import_name == dict1['name']:
                        print(dict1)

            elif select2 == '3':
                import2_stu = input('请输入学号:')
                for dict2 in students:
                    if import2_stu == dict2['stu']:
                        print(dict2)
            else:
                break


# def modify_student_information():
#     """修改学生信息"""
    elif select == '3':
        while True:
            print('''
            1.修改名字
            2.修改年龄
            3.修改电话
            4.返回
            ''')
            select7 = input('请选择(1-4):')
            if select7 == '1':
                name = input('请输入名字:')
                for dict1 in students:
                    if name == dict1['name']:
                        print(dict1)
                        new_name = input('请输入修改后的名字:')
                        dict1['name'] = new_name
                        print('修改成功', dict1)
                    else:
                        print('没有这个人!!!')
                        break

            elif select7 == '2':
                name = input('请输入名字:')
                for dict1 in students:
                    if name == dict1['name']:
                        print(dict1)
                        new_age = input('请输入修改后的年龄:')
                        dict1['age'] = new_age
                        print('修改成功', dict1)
                    else:
                        print('没有这个人!!!')
                        break

            elif select7 == '3':
                name = input('请输入名字:')
                for dict1 in students:
                    if name == dict1['name']:
                        print(dict1)
                        new_tel = input('请输入修改后的名字:')
                        dict1['tel'] = new_tel
                        print('修改成功', dict1)
                    else:
                        print('没有这个人!!!')
                        break
            else:
                break


# def delete_the_student():
#     """删除学生"""
    elif select == '4':
        while True:
            print('''
            1.按学号删除
            2.按姓名删除
            3.返回
            ''')
            select4 = input('请输入(1-4):')
            if select4 == '1':
                new_stu = input('输入学号:')
                for dict1 in students:
                    if new_stu == dict1['stu']:
                        print(dict1)
                        print('''
                        1.确定删除
                        2.返回
                        ''')
                        select5 = input('请选择(1-2):')
                        if select5 == '1':
                            students.pop(dict1)
                        else:
                            break
            elif select4 == '2':
                new_name = input('输入姓名:')
                for dict2 in students:
                    if new_name == dict2['name']:
                        print(dict2)
                        print('''
                            1.确定删除
                            2.返回
                                                ''')
                        select6 = input('请选择(1-2):')
                        if select6 == '1':
                            students.pop(dict2)
                        else:
                            break
            else:
                break
    else:
        break

相关文章

网友评论

      本文标题:学生管理系统简洁版

      本文链接:https://www.haomeiwen.com/subject/skiprqtx.html