zoukankan      html  css  js  c++  java
  • 打印

    打印函数:print

    Python3中,print后要加括号:print()

    print("练习7:更多打印")
    
    #打印句子
    print("solo had a little lamb.")
    print("Its fleece was white as %s." %'snow')
    print("And everywhere that Mary went.")
    print("." * 10) #打印出10个点
    
    #字符串给变量
    end1 = "C"
    end2 = "h"
    end3 = "e"
    end4 = "e"
    end5 = "s"
    end6 = "e"
    end7 = "B"
    end8 = "u"
    end9 = "r"
    end10 = "g"
    end11 = "e"
    end12 = "r"
    #打印
    print(end1 + end2 + end3 + end4 + end5 + end6 ,end = " ")  # end = "" 表示下一行打印时不换hang;引号中间可加入空格、字符等
    print(end7 + end8 + end9 + end10 + end11 + end12)
    print("." * 10)

    结果:

    习题8:

    print("习题8:打印,打印")
    
    #变量指向格式化的字符串
    formatter = "%r %r %r %r"
    
    print (formatter %(1,2,3,4))#格式化的字符串被分别赋值1234
    print(formatter %("one","two","three","four"))
    print(formatter %(True,False,False,True))
    print(formatter %(formatter,formatter,formatter,formatter))
    print(formatter %(
        "I had this ting.",
        "That you could type up right.",
        "But it did't sing.",
        "so I said goodnight."
    ))

    结果:

    习题9:

    print("习题9:打印,打印,打印")
    
    days = "Mon Tue Wed Thu Fri Sat Sun"
    #
     表示换行
    months = "
    Jan
    Feb
    Mar
    Apr
    May
    Jun
    Jul
    Aug"  
    
    #打印出句子
    print("Here are the days:",days)
    print("Here are the months:",months)
    
    #三引号适用于多行句子打印
    print(
    """
    there's somthing going on here.
    with the three double-quotes.
    we'll be able to type as much as we like.
    Even 4 lines if we went,or 5,or 6.
    """
    )

    结果:

  • 相关阅读:
    改 hadoop ssh 端口
    java.lang.OutOfMemoryError: Java heap space 解决方法
    LucidGaze for Solr 搜索监测工具
    hadoop 文件浏览器
    CF1427C Solution
    技术经理必备的六个好习惯
    今天申请博客
    同志们都走了!!
    好笑
    今天看了《浅谈多态》这篇文章
  • 原文地址:https://www.cnblogs.com/aszeno/p/9146002.html
Copyright © 2011-2022 走看看