标签:ssd ror tac rip lock 三次 img put 技术分享
题目:
1.输入用户名密码
2.认证成功后显示欢迎信息
3.输错三次后锁定
1 #!/usr/bin/env python 2 import sys,pickle 3 account = {‘wyh‘:123,‘cloudsea‘:456} 4 l =[] 5 i = 0 6 j = 0 7 f1 = open(‘lock.txt‘,‘r‘) 8 p = f1.readlines() 9 for line in p: 10 s = line.strip(‘\n‘) 11 l.append(s) 12 f1.close() 13 while True: 14 name = input(‘Please input your account:‘).strip() 15 if name not in account.keys(): 16 print (‘your account error,please input agen!‘) 17 i += 1 18 if i == 3: 19 print(‘You tried too many times!‘) 20 sys.exit() 21 continue 22 elif name in l: 23 print(‘Your account has been locked!‘) 24 sys.exit() 25 while True: 26 passd = int(input(‘Password:‘)) 27 if passd != account[name]: 28 print(‘your password error,please try agen!‘) 29 j += 1 30 if j == 3: 31 f = open(‘lock.txt‘,‘a‘) 32 f.write(name + ‘\n‘) 33 f.flush() 34 f.close() 35 print(‘Your account is locked, please contact your administrator!‘) 36 sys.exit() 37 continue 38 break 39 break 40 print (‘Welcome %s into this program!‘% name)
标签:ssd ror tac rip lock 三次 img put 技术分享
原文地址:http://www.cnblogs.com/cloud-80808174-sea/p/6703320.html