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
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步