Multiline strings in Jupyter notebook Multiline strings in Jupyter notebook python-3.x python-3.x

Multiline strings in Jupyter notebook


Use Python's triple quote notation to define a multi-line string:

x = """\Select * FROM OURDBNAME.dbo.vw_DimFoo"""print(x)

results in

Select * FROM OURDBNAME.dbo.vw_DimFoo

(The backslash "\" at the beginning suppresses a line break. To define a single-line string using several lines, add backslashes after each line.)


Using round brackets will allow you to split your string over multiple lines. If you do not use an operator, python will simply concate.

So quick example:

x = (  'Select * '  'FROM OURDBNAME.dbo.vw_DimFoo '  'WHERE <foo> ')print(x)

prints

Select * FROM OURDBNAME.dbo.vw_DimFoo WHERE <foo>