长字符串

  要表示很长的字符串(跨越多行的字符串),可使用三个单引号或三个双引号。

>>> print('''This is a long story.            >>> print("""This is a long story.
... It continues here.                     ... It continues here.
... And it not over yet.                      ... And it not over yet.
... Hello World''')                           ... Hello World""")
This is a long story.                         This is a long story.
It continues here.                         It continues here.
And it not over yet.                         And it not over yet.
Hello World                               Hello World

  常规字符串也可跨越多行,只要在行尾加上反斜杠(‘’),但其只输出一行。

>>> print('This is a long story.
... It continues here.
... And it not over yet.
... Hello World')
This is a long story.It continues here.And it not over yet.Hello World
原文地址:https://www.cnblogs.com/wgbo/p/9571056.html