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")

最新文章

  1. BW知识问答汇总
  2. HTML5翻页电子书
  3. C#怎么遍历一个对象里面的全部属性?
  4. [网络安全] [视频分享]KaLi Linux基础培训2016 最新的哦【福吧资源网】
  5. spring ioc DI 理解
  6. 关于SSH整合中对于Hibernate的Session关闭的问题
  7. 转:[gevent源码分析] 深度分析gevent运行流程
  8. Android下二维码的扫描
  9. 在 Transact-SQL 中使用 TRY...CATCH
  10. JavaEE SSH框架整合(三) struts2 异常、http错误状态码处理
  11. Oracle数据库常用函数
  12. 11_RHEL安装Maya2015
  13. poj2000---和1969一样的模板
  14. 【Cocos2d-X游戏实战开发】捕鱼达人之单例对象的设计(二)
  15. Storm常见问题处理
  16. 纯css实现横向下拉菜单
  17. lintcode 132 模式
  18. Intellij idea破解办法
  19. android 网络工具 之Android-Volley的demo
  20. day_8文件的操作

热门文章

  1. macaca 初试
  2. ie11兼容
  3. 【转】在Express项目中使用Handlebars模板引擎
  4. 笨办法学python 文本复制
  5. Scrapy框架学习第二天
  6. Hibernate的增删改查(事务)
  7. 无界鼠标 Mouse Without Borders
  8. D3算法编写决策树
  9. react系列笔记:第三记-redux-saga
  10. ansj分词