python实现登录函数,比较简单
一个简单的python实现登录以及修改密码的函数
1 #密码错误3次,锁定登录: 2 password_list = ['*#*#','123456'] 3 def account_login(): 4 Tries = 3 5 while Tries > 0: 6 pwd = input('Please input you password:') 7 password_correct = pwd == password_list[-1] 8 password_reset = pwd == password_list[0] 9 if password_correct: 10 print ('Login success!') 11 elif password_reset: 12 New_password = input('Please input a New password!') 13 password_list.append(New_password) 14 print ('password changed successfully!') 15 account_login() 16 else: 17 print ('Wrong password or invalid input!') 18 Tries = Tries - 1 19 print (Tries,'times lift!') 20 else: 21 print ('You accout have suspended!') 22 account_login()
输入*#*#修改密码
2016-10-2816:49:18