Python > multiline stringsの内容表示の違い > print / automatic echoing done by the interactive interpreter


動作環境
Xeon E5-2620 v4 (8コア) x 2
32GB RAM
CentOS 6.8 (64bit)
openmpi-1.8.x86_64 とその-devel
mpich.x86_64 3.1-5.el6とその-devel
gcc version 4.4.7 (とgfortran)
NCAR Command Language Version 6.3.0
WRF v3.7.1を使用。
Python 2.6.6

@ Introducing Python: Modern Computing in Simple Packages by Bill Lubanovic
(No. 802 / 12833)

"""'''を使ったmultiline stringsの場合の内容表示について、以下の違いが記載されている。

  1. print()
  2. automatic echoing done by the interactive interpreter:

適当な文章で試してみた。

>>> poem='''She sells seashells at the seashore.
...         Mirror mirror on the wall who is the fairest of them all?
...         A lie is a lie is a lie, no matter how white, how small,
...         how incorporating of a smidgen of truth there be in it.'''
>>> print(poem)
She sells seashells at the seashore.
        Mirror mirror on the wall who is the fairest of them all?
        A lie is a lie is a lie, no matter how white, how small,
        how incorporating of a smidgen of truth there be in it.
>>> poem
'She sells seashells at the seashore.\n        Mirror mirror on the wall who is the fairest of them all?\n        A lie is a lie is a lie, no matter how white, how small,\n        how incorporating of a smidgen of truth there be in it.'

automatic echoing時は内容の前後に"'(シングルクォーテーション)"が付き、改行記号も\nとして表示される。