Python> Difference in content display of multiline strings> print / automatic echoing done by the interactive interpreter

Operating environment


Xeon E5-2620 v4 (8 cores) x 2
32GB RAM
CentOS 6.8 (64bit)
openmpi-1.8.x86_64 and its-devel
mpich.x86_64 3.1-5.el6 and its-devel
gcc version 4.4.7 (And gfortran)
NCAR Command Language Version 6.3.0
WRF v3.7.Use 1.
Python 2.6.6

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

The following differences are described regarding the content display in the case of multiline strings using " "" and'''.

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

I tried it with an appropriate sentence.

>>> 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.'

At the time of automatic echoing, "'(single quotation)" is added before and after the content, and the line feed symbol is also displayed as \ n.

Recommended Posts

Python> Difference in content display of multiline strings> print / automatic echoing done by the interactive interpreter
Find the difference in Python
Specify the encoding of the unicode string in the Python 2.x print statement
[Python] Display only the elements of the list side by side [Vertical, horizontal]
[Understanding in the figure] Management of Python virtual environment by Pipenv
[Cloudian # 9] Try to display the metadata of the object in Python (boto3)
Read the standard output of a subprocess line by line in Python
Waveform display of audio in Python
Change the length of Python csv strings
Check the behavior of destructor in Python
Display a list of alphabets in Python 3
Display Python 3 in the browser with MAMP
[Python] Understand the content of error messages
Run the Python interpreter in a script
The result of installing python in Anaconda
Read the file line by line in Python
Read the file line by line in Python
The basics of running NoxPlayer in Python
Pandas of the beginner, by the beginner, for the beginner [Python]
Bulk replacement of strings in Python arrays
In search of the fastest FizzBuzz in Python
Let's automatically display the lyrics of the song being played on iTunes in Python
Divides the character string by the specified number of characters. In Ruby and Python.
Get Unix time of the time specified by JST regardless of the time zone of the server in Python
Get the last element of the array by splitting the string in Python and PHP