SoFunction
Updated on 2024-11-18

String internal newline methods in python

There are two ways to line break inside a string in python (using a single print to print multiple lines of the string).

The first method of using \n is surely known to everyone.

Then there's the big method of using ''' three single quotes.

After typing print('''line1 on the interactive command line, the cursor automatically jumps to the next line and the prompt changes from >>> to... After this continue to enter the contents of the next line can be.When you finish typing the content, add ''') at the end and enter again!

When compiling a program in the compiler, it's similar to the command line, except that you don't get a prompt.

The output is:

The above method of internal line breaks for strings in python is all that I have shared with you, and I hope it will give you a reference, and I hope you will support me more.