zoukankan      html  css  js  c++  java
  • For 循环

    _user = "Alex"
    _pwd = "123"
    flag = False
    for i in range(3):
        user_input = input("Enter your login user:")
        pwd_input = input("Enter your login password:")
        if user_input == _user and pwd_input == _pwd:
            print("Hi , %s , Wellcome login you CSDN." % user_input)
            flag = True
            break
        else:
            print("Your user or password not right!")
    if not flag:
        print("小婊砸,你已经试了 %d" % (i+1),"次了!别玩了,程序已经停下来了")
    
    _user = "Alex"
    _pwd = "123"
    counter = 0
    while counter < 3:
        username = input("Enter your login user:")
        pwssword = input("Enter your login password:")
        if username == _user and pwssword == _pwd:
            print("Hi , %s , Wellcome login you CSDN." % username)
            break # break for 后,就不会执行最下面的else语句
        else:
            print("Your user or password not right!")
            counter += 1
    else:#只要上面的for循环正常执行完毕,中间没有被打断,就会执行else语句
        print("小婊砸,你已经试了 %d" % (counter),"次了!别玩了,程序已经停下来了")
    

    重点

    _user = "Alex"
    _pwd = "123"
    for i in range(3):
        username = input("Enter your login user:")
        pwssword = input("Enter your login password:")
        if username == _user and pwssword == _pwd:
            print("Hi , %s , Wellcome login you 博客园." % username)
            break # break for 后,就不会执行最下面的else语句
        else:
            print("Your user or password not right!")
    else:#只要上面的for循环正常执行完毕,中间没有被打断,就会执行else语句
        print("大兄弟,你已经试了 %d" % (i+1),"次了!别玩了,程序已经停下来了")
    
  • 相关阅读:
    ArcGIS中的VBA修复
    ArcSDE解除图层锁定
    Sanboxie 5.14安装图解
    获取WIFI密码
    ArcGIS安装错误1402
    地图中插入表格——ArcMap篇
    mysql 5.6 datetime 保存精确到秒
    JAVA8 ARRAY、LIST操作 汇【5】)- JAVA8 LAMBDA LIST统计(求和、最大、最小、平均)
    cloud配置中心遇到的坑
    解决 MySQL 比如我要拉取一个消息表中用户id为1的前10条最新数据
  • 原文地址:https://www.cnblogs.com/surenliu/p/12736481.html
Copyright © 2011-2022 走看看