美文网首页
day11-学生管理系统2

day11-学生管理系统2

作者: 杨海py | 来源:发表于2018-11-17 10:38 被阅读0次
def stu_management_login_interface():
    page = """===================================
    ❀❀欢迎进入学生管理登录界面
        
        ❤   1.  登录
        ❤   2.  注册
        ❤   3.  返回
            
    ===================================
    """
    page1 = """=========================
        ❀❀欢迎yanghai

            ❤ 1.  查看用户
            ❤ 2.  删除用户
            ❤ 3.  返回
            
    =========================
    """
    page2 = """=========================
            ❀❀欢迎yanghai

                ❤ 1.  进入用户管理系统
                ❤ 2.  进入学生管理系统
                ❤ 3.  返回

        =========================
        """
    list_userinfo = [{'姓名': '杨海', '电话': '15766666666', '账号': 'q1006895418', '密码': '123456'}]
    dict_a_user_information = {}
    num0 = 0

    def register():
        name_value = input('请输入姓名:')
        phone_value = input('请输入电话:')
        account_number = input('请输入账号:')
        for x in list_userinfo:
            if account_number != x['账号']:
                import copy
                print('账号可使用,请继续!')
                password = input('请输入密码:')
                dict_a_user_information['姓名'] = name_value
                dict_a_user_information['电话'] = phone_value
                dict_a_user_information['账号'] = account_number
                dict_a_user_information['密码'] = password
                dict1 = copy.deepcopy(dict_a_user_information)
                list_userinfo.append(dict1)
                print('注册成功!')

    def login_system():
        account_number = input('请输入账号:')
        for x in list_userinfo:
            if account_number == 'q1006895418':
                password = input('请输入密码:')
                while password == x['密码']:
                    print(page2)
                    num4 = input('请选择(1-3):')
                    while num4 == '1':
                        print(page1)
                        num5 = input('请选择(1-3):')
                        if num5 == '1':
                            find_all_user()
                        if num5 == '2':
                            del_user()
                        if num5 == '3':
                            break
                    if num4 == '2':
                        stu_management_system()
                    if num4 == '3':
                        break
                break
            else:
                if account_number == x['账号']:
                    print('账号存在,请继续!')
                    password = input('请输入密码:')
                    if password == x['密码']:
                        print('密码正确,正在进入系统,请稍等!')
                        stu_management_system()

    def find_all_user():
        for x in list_userinfo:
            print(x)
        print('查找成功!')

    def del_user():
        account_number = input('请输入账号:')
        for x in list_userinfo:
            if account_number == x['账号']:
                if account_number != 'q1006895418':
                    print(x)
                    print('1.确定删除')
                    print('2.返回')
                    num = input('请选择(1-2):')
                    if num == '1':
                        list_userinfo.remove(x)
                        print('删除成功!')
                else:
                    print('不能删除自己!')

    def stu_management_system():
        page3 = """=========================
            ❀❀欢迎yanghai

                ❤ 1.  添加学生
                ❤ 2.  查看学生
                ❤ 3.  修改学生信息
                ❤ 4.  删除学生
                ❤ 5.  返回
        =========================
        """
        page4 = """
            1.查看所有学生
            2.按姓名查找
            3.按学号查找
            4.返回
        """
        list_student_information = []
        dict_student_information = {}
        # str_stu_number = ''
        num = 0

        def numbers():
            for x in range(1000):
                yield x

        gener = numbers()

        def add_student_information():
            import copy
            name_value = input('请输入姓名:')
            age_value = input('请输入年龄:')
            phone_value = input('请输入电话:')
            stu_number = str(next(gener))
            str_stu_number = stu_number.rjust(4, '0')
            dict_student_information['学号'] = str_stu_number
            dict_student_information['姓名'] = name_value
            dict_student_information['年龄'] = age_value
            dict_student_information['电话'] = phone_value
            dict1 = copy.deepcopy(dict_student_information)
            list_student_information.append(dict1)
            print('添加成功!')
            print('1.继续')
            print('2.返回')

        def find_all_student():
            for x in list_student_information:
                print(x)
            print('查找成功!')

        def find_by_name():
            name = input('请输入姓名:')
            for x in list_student_information:
                if name == x['姓名']:
                    print(x)
            print('查找成功!')

        def find_by_student_number():
            student_number = input('请输入学号:')
            for x in list_student_information:
                if student_number == x['学号']:
                    print(x)
            print('查找成功!')

        def revise_stu_information():
            name_value = input('请输入姓名:')
            age_value = input('请输入年龄:')
            phone_value = input('请输入电话:')
            stu_number = input('请输入学号:')
            for x in list_student_information:
                if stu_number == x['学号']:
                    x['姓名'] = name_value
                    x['年龄'] = age_value
                    x['电话'] = phone_value
                    print('修改成功!')
                    print('1.继续')
                    print('2.返回')
                    break
            else:
                print('学号不正确')

        def del_stu_information():
            name = input('请输入姓名:')
            count = 0
            list1 = []
            for x in list_student_information:
                if name == x['姓名']:
                    list1.append(x)
                    count += 1
            if count > 1:
                for y in range(len(list1)):
                    print(y, list1[y])
                num1 = int(input('请选择:'))
                list_student_information.remove(list1[num1])
                print('删除成功!')
            elif count == 1:
                list1.remove(list1[0])
                print('删除成功!')
            else:
                print('没有该学生!')

        while num == 0:
            print(page3)
            num7 = int(input('请选择(1-5):'))
            while num7 == 1:
                add_student_information()
                num8 = int(input('请选择(1-2):'))
                if num8 == 2:
                    break
            while num7 == 2:
                print(page4)
                num2 = int(input('请选择(1-4):'))
                if num2 == 1:
                    find_all_student()
                if num2 == 2:
                    find_by_name()
                if num2 == 3:
                    find_by_student_number()
                if num2 == 4:
                    break
            while num7 == 3:
                revise_stu_information()
                num3 = int(input('请选择(1-2):'))
                if num3 == 2:
                    break
            if num7 == 4:
                del_stu_information()
            if num7 == 5:
                print('成功退出学生管理系统!')
                num = 'end!'

    while num0 == 0:
        print(page)
        num6 = input('请选择(1-3):')
        if num6 == '1':
            login_system()
        elif num6 == '2':
            register()
        else:
            print('成功退出登录界面!')
            break


stu_management_login_interface()

相关文章

网友评论

      本文标题:day11-学生管理系统2

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