欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

《笨办法学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"
))

运行结果:
《笨办法学python3-Learn Python 3 the HARD WAY》-习题8 打印,打印
知识点:
print (formatter.format(1, 2, 3, 4))
变量定义时未给出具体内容只定义了{},后面print (formatter.format(1, 2, 3, 4))格式化输出的内容为format(1, 2, 3, 4)括号内的内容。