0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

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

Last updated at Posted at 2017-01-18
動作環境
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として表示される。

0
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?