zoukankan      html  css  js  c++  java
  • 代码1(while循环和IF条件语句,字符格式化,break,continue)

    #三次登是否继续
    count = 1
    while count<=3:
    username = input('请输入用户名:')
    password = input('请输入密码')
    n = 3-count
    if username == 'whzc' and password == 'whzc':
    print('欢迎登录')
    break
    else:
    template = "用户名或密码错误,您还有%s次机会."%(n)
    #字符格式化
    print(template)

    if count==3:
    choice = input('请输入是否继续(Y/N')
    if choice=='N':
    break
    elif choice=='Y':
    count = 1
    continue
    else:
    print('输入错误')
    break
    count+=1
    #递减少代
    count = 2
    while count>=0:
    usr = input('请输入用户名:')
    pwd = input('请输入密码:')
    if usr=='whzc' and pwd=='whzc':
    print('欢迎登录。')
    break
    template='用户名或密码错误,您还有%s次机会。'%(count,)
    #字符格式化%s %号内变count后面加逗
    print(template)
    if count == 0:
    choice = input('请输入是否继续(Y/N')
    if choice=='N':
    break
    elif choice=='Y':
    count = 2
    continue
    else:
    print('输入错误')
    break
    count-=1
    #break是跳出当前循环,而continue是回到while循环开始。
  • 相关阅读:
    关于feign调用请求头丢失分析
    并发下编写SQL的注意事项
    Sentinel降级规则整理
    Mybatis-Plus使用整理
    Docker各种零散命令整理
    set集合怎么保证不重复的
    idea启动项目ava heap space
    网络穿透工具--钉钉HTTP穿透
    Log4j基本使用
    ide中普通java程序打包
  • 原文地址:https://www.cnblogs.com/witchingsong/p/12143516.html
Copyright © 2011-2022 走看看