How would you go about converting a string into a triple quoted string?
x = "y"
into:
x = """y"""
How would you go about converting a string into a triple quoted string?
x = "y"
into:
x = """y"""
You don't. A tripple-quoted string is just notation sugar, it results in a normal Python string regardless:
>>> x = "y"
'y'
>>> x = """y"""
'y'
You use tripple quotes to make inclusion of newlines easier:
"""\
Some longer string
with newlines in the text
is easier this way.
"""
is easier to read than:
"Some longer string\nwith newlines in the text\nis easier this way.\n"
but the end result for these two ways of declaring a string value is exactly the same.
You can escape quotes using \ character. I don't know exactly how does Python contacnate strings, but it would look similar to:
x = "\"\"y\"\"";