Python has a triple-quoted string literal format, sometimes called a block string.
It is a syntactic convenience for coding multiline text data.
This form begins with three quotes (of either the single or double variety), is followed by any number of lines of text, and is closed with the same triple-quote sequence that opened it.
Single and double quotes embedded in the string's text may be escaped.
t = """this is a test.""" # w w w. j a v a 2s . co m print( t )
Here, this string spans three lines.
Triple-quoted strings will retain all the enclosed text, including comments.
t = """this # comments is a test.""" # w w w .j av a 2 s. c o m print( t )
Triple-quoted strings are useful to encode multiline text in your program.
For example, to embed multiline error messages or HTML, XML, or JSON code in your Python source code files.
Triple-quoted strings are also used for documentation strings.
You can use triple-quoted strings to temporarily disable lines of code during development.
To turn off a few lines of code and run your script again, simply put three quotes above and below them, like this:
X = 1
"""
import os # Disable this code temporarily
print(os.getcwd())
"""
Y = 2