笨办法学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习题6 字符串和文本