1 [[email protected] ~]# cat 7.py 2 #!/usr/bin/python 3 # -*- coding=UTF-8 -*- 4 5 usera_name = ‘usera‘ 6 usera_passwd = ‘aresu‘ 7 usera_status = ‘on‘ 8 userb_name = ‘userb‘ 9 userb_passwd = ‘bresu‘ 10 userb_status = ‘on‘ 11 ng = 0 12 13 14 name = raw_input(‘请输入用户名:‘) 15 16 while ng < 3: 17 if name == usera_name: 18 passwd = raw_input(‘请输入密码 :‘) 19 if passwd == usera_passwd: 20 print ‘欢迎回来 usera !!!‘ 21 break 22 else: 23 ng += 1 24 if ng == 3: 25 print ‘密码输入错误三次,账号已锁定 !!!‘ 26 usera_status = ‘off‘ 27 break 28 elif name == userb_name: 29 passwd = raw_input(‘请输入密码 :‘) 30 if passwd == userb_passwd: 31 print ‘欢迎回来 userb !!!‘ 32 break 33 else: 34 ng += 1 35 if ng == 3: 36 print ‘密码输入错误三次,账号已锁定 !!!‘ 37 usera_status = ‘off‘ 38 break 39 else: 40 print ‘用户不存在,请重新执行‘ 41 break 42 43 print usera_name,usera_status 44 print userb_name,userb_status 45 46 [[email protected] ~]# python 7.py 47 请输入用户名:usera 48 请输入密码 :1 49 请输入密码 :2 50 请输入密码 :3 51 密码输入错误三次,账号已锁定 !!! 52 usera off 53 userb on 54 [[email protected] ~]# python 7.py 55 请输入用户名:userb 56 请输入密码 :3 57 请输入密码 :2 58 请输入密码 :1 59 密码输入错误三次,账号已锁定 !!! 60 usera off 61 userb on 62 [[email protected] ~]# python 7.py 63 请输入用户名:sun 64 用户不存在,请重新执行 65 usera on 66 userb on 67 [[email protected] ~]# python 7.py 68 请输入用户名:usera 69 请输入密码 :aresu 70 欢迎回来 usera !!! 71 usera on 72 userb on
时间: 2024-10-21 00:51:07