zoukankan      html  css  js  c++  java
  • Python(24)_格式化输出

    #-*-coding:utf-8-*-
    '''
    The use of format
    %s The use of %s 
    '''
    name = input("Input your name:")
    age  = input("Input your age:")
    height = input("Input your height:")
    msg = '我叫%s,今年%s 高%s'%(name,age,height)
    print(msg)


    #-*-coding:utf-8-*-
    '''
    The use of format
    %s The use of %s
    '''
    name = input("Input your name:")
    age  = input("Input your age:")
    job  = input("Input your work:")
    hobbie = input("Input your hobbie:")
    msg = '''---------------------index of %s -------------
    Name   :  %s
    Age    :  %d
    Job    :  %s
    Hobbie :  %s
    ---------------------end --------------------------''' %(name,name,int(age),job,hobbie)
    
    print(msg)

       二、 三次登录程序优化


    #-*-coding:utf-8-*-
    '''
    '''
    i=0
    username = 'bowen'
    password = '123'
    while i<3:
        name = input('Input your name:')
        pwd  = input('Input your password:')
        if username == name and password == pwd:
            print("Congrations,Login in Success!")
            break
        else:
            print('failed to login in,you still have %d times to try ' %(2-i))
            if(2-i)==0:
                result = input("You still want to try?Y or N")
                if result == 'Y':
                    i==0
                    continue
        i +=1
    else:print('fuck you!')

    这是对昨天的那个while程序的优化。输入三次错误的。最后不管是输入Y还是N,都会弹出fuck you

  • 相关阅读:
    微信小程序的scheme码
    微信小程序的简单总结(uni-app)
    ES7-ES11新特性
    Promise 总结
    uni-app创建项目及使用 vant-weapp
    vscode 插件整理
    el-upload 组件总结
    从输入URL到页面显示过程中发生了什么
    实验 1:Mininet 源码安装和可视化拓扑工具
    2020软件工程第一次作业
  • 原文地址:https://www.cnblogs.com/sunnybowen/p/10197614.html
Copyright © 2011-2022 走看看