登录操作(方法一:设置flag标志位)

user_name="star"
passwoed='123'
passed_authentication=False
count=0
for i in range(3):
u_username=input("please input your username:")
u_password=input("please input your password:") if u_username==user_name and u_password==passwoed:
print("welcome to %s"%u_username)
passed_authentication=True
break
else:
count+=1
print("your username or password is Error")
if not passed_authentication:
count==3
print("you have try more times,would you want to try again? please input yes or no,please choose")
answer=input("your choose:")
if answer=='yes':
print("go away,hahahah") Input:正确操作

please input your username:qwe
please input your password:222
your username or password is Error
please input your username:star
please input your password:123
welcome to star

进程已结束,退出代码0

Output:错误操作

please input your username:aa
please input your password:aa
your username or password is Error
please input your username:aa
please input your password:aa
your username or password is Error
please input your username:aa
please input your password:aa
your username or password is Error
you have try more times,would you want to try again? please input yes or no,please choose
your choose:yes
go away,hahahah

进程已结束,退出代码0

最新文章

  1. C#字符串的倒序输出
  2. jQuery代码优化:事件委托篇
  3. 6种编写HTML和CSS的最有效的方法
  4. 51nod1269 B君的圆锥
  5. Oracle 经典语法(二)
  6. 【HDOJ】4373 Mysterious For
  7. Asp.Net MVC 模型(使用Entity Framework创建模型类) - Part.1
  8. [Ember] Wraming up
  9. HDU 5904 LCIS
  10. 【js 编程艺术】小制作一
  11. springboot+mybatis+ehcache实现缓存数据
  12. WMI测试器
  13. [Sublime]Sublime安装以及插件使用
  14. React Native的语法之ES5和ES6
  15. Shell脚本开发过程中遇到的问题处理
  16. 首次编译Java小程序
  17. Java基础-类和对象
  18. docker之docker-machine用法
  19. 解决Oracle EM 乱码问题
  20. jquery miniui 学习笔记

热门文章

  1. 多个串的最长公共子串 SPOJ - LCS2 后缀自动机
  2. JQuery日记6.7 Javascript异步模型(二)
  3. 对TextVIew中特定字符串设定onTouchEvent方法
  4. xinetd - 扩展的互联网服务守护进程
  5. CentOS7.6安装Go-1.12.9
  6. 修改docker镜像地址
  7. Sublime Text3中MarkDown的使用
  8. C# 模拟http请求网页数据 [网页爬虫]
  9. java script 数组去重两种方法
  10. NOIp2018集训test-9-5(am)