import sys
login_error_number = 0
login_pwd = 'abc@123'

def login(pwd, user_pwd):
    global login_error_number
    if pwd == user_pwd:
        print('请输入正确密码:')
        login_error_number = 0
        return True
    else:
        login_error_number += 1
        print(f'警告!您已经输入密码错误{login_error_number}次!')
        if login_error_number >= 3:
            print('您已经输入密码错误超过3次\n账号已冻结!')
            sys.exit()
        else:
            return False

is_logged_in = False

while not is_logged_in:
    input_pwd = input('请输入您的密码:')
    is_logged_in = login(input_pwd, login_pwd)

print('登录成功!')
最后修改:2024 年 01 月 24 日
咱们谁跟谁,用不着~