Python - Multi line string

Introduction

Python allows strings to be enclosed in single or double quote characters.

They mean the same thing but allow the other type of quote to be embedded with an escape.

Python allows multiline string literals enclosed in triple quotes.

When triple quotes is used, all the lines are concatenated together, and end-of-line characters are added where line breaks appear.

It is useful for embedding things like multiline HTML, XML, or JSON code in a Python script:

Demo

msg = """ 
this is a test# ww  w .j  a va  2 s  . c  om
 bbb'''bbbbbbbbbb""bbbbbbb'bbbb 
hi
""" 
print( msg )

Result

Related Topic