天天看點

《笨辦法學python3-Learn Python 3 the HARD WAY》-習題8 列印,列印

學習内容:

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)括号内的内容。

繼續閱讀