美文网首页
登录注册

登录注册

作者: 2333_11f6 | 来源:发表于2018-11-20 09:53 被阅读0次
    
    
    def login_page():
        print("""******************************************************
    ******************************************************
    **           欢迎来到LOL小学生管理系统              **
    **                 💗 1.登录                        **
    **                 💗 2.注册                        **
    **                 💗 3.退出                        **
    ******************************************************
    ******************************************************""")
    
    
    def show_aap():
        list1 = []
        with open('account_and_password.txt', 'r', encoding='utf-8') as aap:
            list0 = aap.read().splitlines()  # 按换行符切割,默认不保留换行符
        for item in list0:
            list1.append(item.split('/', 1))
        return list1
    
    
    bool1 = True
    while bool1:
        login_page()
        choice = input('请选择(1-3):')
        if choice == '1':
            bool2 = True           # 写在这用于更新
            while bool2:
                account = str(input('请输入账号名:'))
                password = str(input('请输入密码:'))
                if len(show_aap()) == 0:
                    print('账号不存在,请先注册!')
                    break
                else:
                    aap_dict = dict(show_aap())
                    # print(account, password)
                    for key in aap_dict:
                        # print(aap_dict)
                        if account == key and password == aap_dict[key]:
                            print('登录成功!')
                            bool1 = bool2 = False
                            break
                    else:
                        while True:
                            print("""==============================
    账号或密码错误,请选择(1-2):
    💗 1.继续输入
    💗 2.返回
    ==============================""")
                            choice2 = input()
                            if choice2 == '1':
                                break
                            elif choice2 == '2':
                                bool2 = False
                                break
                            else:
                                continue
        elif choice == '2':
            while True:
                account = input('请输入账号名:')
                if len(show_aap()):
                    password = input('请输入密码:')
                    check_password = input('请确认密码:')
                    if check_password == password:
                        with open('account_and_password.txt', 'a',
                                  encoding='utf-8') as aap:
                            aap.write(account + '/' + password + '\n')
                        print('注册成功!请继续!!')
                        break
                else:
                    aap_dict = dict(show_aap())
                    for key in aap_dict:
                        if key == account:
                            print('该账号已被注册,请重新输入!')
                            break
                    else:
                        password = input('请输入密码:')
                        check_password = input('请确认密码:')
                        if check_password == password:
                            with open('account_and_password.txt', 'a', encoding='utf-8') as aap:
                                aap.write(account + '/' + password + '\n')
                            print('注册成功!请继续!!')
                            break
                        else:
                            print('两次密码不一致,请重新设置!')
                            continue
        elif choice == '3':
            print('再见!')
            break
        else:
            continue
    

    相关文章

      网友评论

          本文标题:登录注册

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