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

笨办法学Python 3 习题8

程序员文章站 2022-06-15 18:44:56
...

[交作业啦]
ex8.py

formatter = "{} {} {} {}"

# 对formatter应用格式化,传入4个参数
print(formatter.format(1, 2, 3, 4))
print(formatter.format("one", "two", "three", "four"))
print(formatter.format(True, False, True, False))
print(formatter.format(formatter, formatter, formatter, formatter))
print(formatter.format(
      "Try your",
      "Own text here",
      "Mabye a poem",
      "Or a song about fear"
))

运行结果(会话)

PS E:\lpthw> python .\ex8.py
1 2 3 4
one two three four
True False True False
{} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
Try your Own text here Mabye a poem Or a song about fear
PS E:\lpthw>
相关标签: python