《笨办法学python3-Learn Python 3 the HARD WAY》-习题8 打印,打印
程序员文章站
2022-06-15 18:44:26
...
学习内容:
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(
"Try you",
"Own text here",
"Maybe a poem",
"Or a song about fear"
))
运行结果:
知识点:
print (formatter.format(1, 2, 3, 4))
变量定义时未给出具体内容只定义了{},后面print (formatter.format(1, 2, 3, 4))格式化输出的内容为format(1, 2, 3, 4)括号内的内容。