formatter="{} {} {} {}"#空格隔开
'''
str.format()函数:通过{}和:来代替%,用于格式化字符串
'''
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 your",
"Own text here",
"Maybe a poem",
"Or a song about fear"
))#字符串
输出结果:
1 2 3 4
one two three four
True False False True
{} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
Try your Own text here Maybe a poem Or a song about fear