zoukankan      html  css  js  c++  java
  • Exercise 8: Printing, Printing

    formatter = "%r %r %r %r"
    print formatter % (1, 2, 3, 4)
    print formatter % ("one", "two", "three", "four")
    print formatter % (True, False, False, True)
    print formatter % (formatter, formatter, formatter, formatter)
    print formatter % (
        "I had this thing.",
        "That you could type up right.",
        "But it didn't sing.",
        "So I said goodnight." )

    Notice that the last line of output uses both single and double quotes for individual pieces. Why do you think that is?

    Why does %r sometimes print things with single-quotes when I wrote them with double-quotes.
    Python is going to print the strings in the most efficient way it can, not replicate exactly the way you wrote them. This
    perfectly fine since %r is used for debugging and inspection, so it's not necessary that it be pretty.

  • 相关阅读:
    ThreadLocal
    spring概述
    排序
    内存的分配原则
    常用概念比较
    垃圾回收机制
    java的内存模型
    对象的内存布局
    adb connect 和 install 通讯流程
    Android硬件抽象层(HAL)深入剖析(三)
  • 原文地址:https://www.cnblogs.com/hluo/p/4043027.html
Copyright © 2011-2022 走看看