What is the python newline character?

(*-*)浩
Release: 2019-07-03 14:25:17
Original
14133 people have browsed it

Regarding the issue of line breaks, first ask a question, as follows.

What is the python newline character?

There is python program code: (Recommended learning: Python video tutorial)

print("I'm Bob. What's your name?")
Copy after login

The output of the previous line of code is as follows :

I'm Bob. What's your name?
Copy after login

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?
Copy after login

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?")
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!