1 # 登录操作 2 PassWord_list = [] 3 Reset_pw = '*#*#' 4 def account_login(): 5 if PassWord_list == []: 6 PassWord = input("请设置初始密码:") 7 if PassWord.isalnum(): 8 PassWord_list.append(PassWord) 9 account_login() 10 else: 11 print("密码只能是输入或字母,请重新输入") 12 account_login() 13 else: 14 # print(PassWord_list) 15 num = 3 16 while num > 0: 17 password = input('请输入您的登录密码: ') 18 correct_password = password == PassWord_list[-1] 19 reset_password = password == Reset_pw 20 if correct_password: 21 print("登录成功") 22 quit() 23 elif reset_password: 24 new_password = input('请输入要重置的密码: ') 25 if new_password.isalnum(): 26 PassWord_list.append(new_password) 27 else: 28 print("密码只能是输入或字母,请重新输入") 29 account_login() 30 print('密码已经重置成功,请输入重置的密码登录') 31 account_login() 32 else: 33 print("您输入的密码错误,请再次输入或输入'*#*#'重置密码") 34 num = num -1 35 print(num,'time left') 36 print("输入次数过多") 37 account_login()