笨办法09打印,打印,打印

xiaoxiao2021-02-28  149

# Here's some new strange stuff, remember type it exactly. days = "Mon Tue Wed Thu Fri Sat Sun" months = "Jan\nFeb\nMar\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." """

输出结果:

代码中:\n 表示回车换行,此处\n后若加空格,则换行字符也会空出一格,显示如下:


加入几个\n看一下作用:

print """ There's something going on here.\nWith the three double-quotes.\n We'll be able to type as much as we like. Even 4 lines if we want, or 5, or 6." """

打印结果如下:


若最后一段想使用双引号,可以这么写:在每行最后加上“\”,就是没啥必要╮(╯_╰)╭:

print "There\'s something going on here.\ \nWith the three double-quotes.\ \nWe\'ll be able to type as much as we like.\ \nEven 4 lines if we want, or 5, or 6."

输出结果与使用三个双引号相同

转载请注明原文地址: https://www.6miu.com/read-19956.html

最新回复(0)