笨办法学Python ex08
2016-12-10 本文已影响0人
Joemini
打印, 打印
- 输入:
# -- coding: utf-8 --
formatter = "%r %r %r %r" # 将格式化字符串赋值给变量formatter
print formatter % (1,2,3,4)
print formatter % ("one", "two", "three", "four") # 能将引号获取过来
print formatter % (True, False, False, True)
print formatter % (
"I had this thing.",
"That you could type up right.",
"But it didn't sing.",
"So I said goodnight."
) # 逗号使代码分行,实际打印出来的是在一行
- 运行:

附加题
最后一行代码,打印出来既有单引号,又有双引号,至于原因暂时不知道,