作业一:登陆接口

 1 #作业:登陆接口
 2 user=['test','test1','test2','test3']
 3 password=['test','1test','2test','3test']
 4 count=0
 5 while True:
 6     if count > 2:
 7         print('''
 8   你操作太频繁,请稍后再试!
 9         ''')
10         break
11     name = input('your name: ')
12     pwd = input('your password: ')
13     if  not name in user:
14         print('用户名不存在')
15         continue
16     id=user.index(name)
17     if  pwd == password[id]:
18         print('欢迎登陆!')
19         break
20     else:
21         print('用户名或者密码错误!请重试')
22         count+=1
23 #进阶:
24 user=['test','test1','test2','test3']
25 password=['test','1test','2test','3test']
26 count=0
27 while True:
28     name = input('your name: ')
29     pwd = input('your password: ')
30     with open('denylogin.txt', 'r')  as file:
31         denylist = file.read()
32         if name in denylist:
33             print('你的账户已经锁定,不能登陆,请联系管理员!')
34             break
35     if  not name in user:
36         print('用户名不存在')
37         continue
38     id=user.index(name)
39     if  pwd == password[id]:
40         print('欢迎登陆!')
41         break
42     else:
43         print('用户名或者密码错误!请重试')
44         count+=1
45     if count > 2:
46         print('''你操作太频繁,账户已经锁定''')
47         with open('denylogin.txt','a') as  file :
48             file.write('%s' %name+'\n')
49             break

 

转载于:https://www.cnblogs.com/lincappu/p/8143866.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值