Home > Article > Backend Development > What is the python newline character?
Regarding the issue of line breaks, first ask a question, as follows.
There is python program code: (Recommended learning: Python video tutorial)
print("I'm Bob. What's your name?")
The output of the previous line of code is as follows :
I'm Bob. What's your name?
The above output has no line breaks. I want to wrap the line before What, but the effect is:
I'm Bob. What's your name?
What should I do?
Hit Enter before What, okay? No, the effect of this carriage return is to wrap the statement, not the output content.
Solution using newline character
The solution to the above problem is to insert a newline character before What. The writing is:
print("I'm Bob.\nWhat's your name?")
Did you notice the \n in front of What? This is a combination of characters, a backslash and the n letter. However, the meaning of this combination is only one character, the newline character.
I emphasize again that the writing method is a combination of two characters, but the meaning is only one character.
For more Python-related technical articles, please visit the Python Tutorial column to learn!
The above is the detailed content of What is the python newline character?. For more information, please follow other related articles on the PHP Chinese website!