In Python, you can continue writing content on a new line through the following three methods: Use the "\n" newline character in a string literal. Use triple quotes (''') or triple double quotes ("""") to create a multiline string. Use the operator to concatenate strings and the "\n" newline character.
How to start a new line in Python and continue writing content
In Python, you can use the newline character "\ n" Start a new line and continue writing.
The method is as follows:
text = "这是第一行。\n这是第二行。" print(text)
Output:
<code>这是第一行。 这是第二行。</code>
Can be created in Python using triple quotes (''') or triple double quotes ("""") Multiline string. The following example includes newlines in the string:
text = """ 这是第一行。 这是第二行。 """ print(text)
The output is the same:
<code>这是第一行。 这是第二行。</code>
Operators can be used to concatenate strings together and create newlines.
line1 = "这是第一行。" line2 = "这是第二行。" text = line1 + "\n" + line2 print(text)
Same output:
<code>这是第一行。 这是第二行。</code>
Note: The
The above is the detailed content of How to start a new line and continue writing content in python. For more information, please follow other related articles on the PHP Chinese website!