Learn to Code

《笨办法学Python3》练习八:打印,还是打印

2019-02-28  本文已影响0人  雨开Ame

练习代码

formatter = "{} {} {} {}"

print(formatter.format(1, 2, 3, 4))
print(formatter.format("one", "two", "three", "four"))
print(formatter.format(True, False, False, True))
print(formatter.format(formatter, formatter, formatter, formatter))
print(formatter.format(
    "床前明月光",
    "玻璃好上霜",
    "要不及时擦",
    "整不好就得脏"
))

Study Drills

  1. Do your checks, write down your mistakes, and try not to make the same mistakes on the next exercise. In other words, repeat the Study Drills from Exercise 7.

补充

  1. 没啥好说的,就是把字符串常量替换成了变量,再调用变量的format方法,原理都是相同的。
上一篇 下一篇

猜你喜欢

热点阅读