将打印进行到底。
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Here's some new strange stuff, remember type it exactly
days = "Mon Tue Wed Thu Fri Sat Sun"
months = "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug"
print("Here are the days: ", days)
print("Here are the months: ", months)
print("""
There's something going on here.
With the three double-quotes.
We'll be able to type as much as we like.
Even 4 lines if we want, or 5, or 6.
""")
运行结果:
观察运行结果,不难发现"""可以实现多行的打印,不需要每行都使用一次print函数。
“\n”具有换行的作用。
小结
- “\n”实现换行。
- 对于多行组成的长字符串,可以使用用"""来进行打印,注意中间没有引号之间没有空格。