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

  • 相关阅读:
    Set和Map
    将博客搬至CSDN
    (转)VS制作安装包
    C#俄罗斯方块实现思路及源码
    ASP.NET网站部署过程
    2016百度之星资格赛总结
    数据库编程常见错误总结
    (转)Android 如何全局获取Context
    Android数据文件存储
    关于工程文档中图表的使用
  • 原文地址:https://www.cnblogs.com/sunnybowen/p/10197614.html
Copyright © 2011-2022 走看看