zoukankan      html  css  js  c++  java
  • Python3 适合初学者学习的银行账户登录系统

    一、所用知识点:

      1. for循环与if判断的结合

      2. %s占位符的使用

      3. 辅助标志的使用(标志位)

      4. break的使用

    二、代码示例:

     1 '''
     2 银行登录系统
     3 '''
     4 
     5 uname = "bob"
     6 passwd = 123
     7 judgment = 0
     8 choice = 2
     9 
    10 for i in range(3):
    11     username = input("请输入用户名:")
    12     password = int(input("请输入密码:"))
    13     if username == uname and password == passwd:    #用户名和密码必须同时成立
    14         print("~~~欢迎%s使用银行自助服务系统~~~" %uname)    # %s是占位符
    15         judgment = 1
    16         break
    17     else:
    18         if choice != 0:
    19             print("!!!登陆失败!!!" + "您还有" + str(choice) + "次机会")
    20         else:
    21             print("!!!登陆失败!!!")
    22         choice = choice - 1
    23 if judgment == 0:
    24         print("三次机会已用完,此卡将冻结10分钟")  #只是提示信息,冻结操作并未编写
    25 
    26 
    27 
    28 # 第二种思路
    29 # uname = "bob"
    30 # passwd = 123
    31 #
    32 # choice = 2
    33 #
    34 # for i in range(3):
    35 #     username = input("请输入用户名:")
    36 #     password = int(input("请输入密码:"))
    37 #     if username == uname and password == passwd:
    38 #         print("~~~欢迎%s使用银行自助服务系统~~~" %uname)    # %s是占位符
    39 #
    40 #         break
    41 #     else:
    42 #         if choice != 0:
    43 #             print("!!!登陆失败!!!" + "您还有" + str(choice) + "次机会")
    44 #         else:
    45 #             print("!!!登陆失败!!!")
    46 #         choice = choice - 1
    47 # else:
    48 #     print("三次机会已用完,此卡将冻结10分钟")
    49 # 
    50 #
  • 相关阅读:
    spring中@Autowired与 @Resource区别
    linux系统镜像iso文件下载
    log4j.properties配置说明学习网址
    maven常用命令
    mysql优化
    mybatis与hibernate区别
    struts2与SpringMVC区别
    java同步锁实现方法
    java多线程的四种实现方式
    java单例模式几种实现方式
  • 原文地址:https://www.cnblogs.com/Infi-chu/p/7301629.html
Copyright © 2011-2022 走看看