代码
# Ex9 打印,打印,打印
days = "Mon Tue Wes Thu Fri Sat Sun"
# months = "Jan/nFeb/nMar/nApr/nMay/nJun/nJul/nAug"
# 错误运行结果:Here are the months: Jan/nFeb/nMar/nApr/nMay/nJun/nJul/nAug
months = "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug"
# new line character 换行字符\n
print("Here are the days:", days)
print("Here are the months:", months)
print("""
There's something going on here.
With the three double-quates.
We'll be able to type as much as we like.
Even 4 lines if we want, or 5, or 6.
""")
运行结果
备注
1.三引号内部的代码会自动添加换行符 与原代码书写保持一致
但三引号之间不能加空格 “”“XXX”"" 或’’‘XXX’’’ 使用单引 双引的三引号皆可
2. new line character 换行字符是 \n 注意是反斜杠 方向不能错