How to create a long multi-line string in Python?

PythonServer Side ProgrammingProgramming

To create multiline strings, instead of using one pair of single/double quotes, we use three pairs. For example,

multiline_str = """
My
multi-line
string
"""
print multiline_str

 This will give the output:

  My
  multi-line
  string

 Note that you cannot interpolate strings using this notation. This notation is also used to define docstrings in Python.

raja
Published on 13-Dec-2017 14:35:45
Advertisements