python基础一之课后作业:编写登录接口
2024-08-20 14:31:33
1 # Author : Mamba
2
3 #python基础一之课后作业:编写登录接口
4
5 # 输入用户名密码
6 # 认证成功后显示欢迎信息
7 # 用户名3次输入错误后,退出程序
8 # 密码3次输入错误后,锁定用户名
9 print("------mamba_login------")
10 user = input("please input your username :")
11
12 pwd = 0
13 user_count = 0
14 pwd_count =0
15 isEnd = False
16
17 while user_count < 3 : #当输入的用户名数据小于3次时
18 if isEnd:
19 break
20 if user == "mamba":
21 pwd = input("please input your password :")
22 while pwd_count < 3: #当输入的密码小于3次时
23 if pwd == "":
24 print("welcome mamba come back")
25 isEnd = True
26 break
27 else:
28 pwd_count += 1
29 if 3 != pwd_count:
30 print('{0} {1} {2} {3}'.format('Password is wrong!!!', 'you have', (3 - pwd_count), 'chances.'))
31 pwd = input("please input your password again:")
32 else: #当用户名不对
33 user_count += 1
34 if 3 != user_count:
35 print('{0} {1} {2} {3}'.format('Username is wrong!!!', 'you have', (3 - user_count), 'chances.'))
36 user = input("please input your username again: ")
37 if user_count > 3 or pwd_count > 3 or isEnd == False : #当用户名或密码的次数超过3次
38 print("Wrong!!sorry.")
39 print("you have tried too many times ,game over")
最新文章
- BW知识问答汇总
- HTML5翻页电子书
- C#怎么遍历一个对象里面的全部属性?
- [网络安全] [视频分享]KaLi Linux基础培训2016 最新的哦【福吧资源网】
- spring ioc DI 理解
- 关于SSH整合中对于Hibernate的Session关闭的问题
- 转:[gevent源码分析] 深度分析gevent运行流程
- Android下二维码的扫描
- 在 Transact-SQL 中使用 TRY...CATCH
- JavaEE SSH框架整合(三) struts2 异常、http错误状态码处理
- Oracle数据库常用函数
- 11_RHEL安装Maya2015
- poj2000---和1969一样的模板
- 【Cocos2d-X游戏实战开发】捕鱼达人之单例对象的设计(二)
- Storm常见问题处理
- 纯css实现横向下拉菜单
- lintcode 132 模式
- Intellij idea破解办法
- android 网络工具 之Android-Volley的demo
- day_8文件的操作