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.

  • 相关阅读:
    flask框架的使用
    git的基本使用
    pycharm连接数据库以及遇到的问题
    Git原理与Git命令大全
    git使用
    Redis 数据库
    ATM项目
    跨域问题及解决方案
    django的信号
    django的缓存机制
  • 原文地址:https://www.cnblogs.com/hluo/p/4043027.html
Copyright © 2011-2022 走看看