Home  >  Article  >  Backend Development  >  What is the newline character in Python?

What is the newline character in Python?

烟雨青岚
烟雨青岚Original
2020-06-18 16:28:4112789browse

What is the newline character in Python?

#What is the newline character in python?

#The python newline character is "\n".

Windows newline character is '\r\n',

Unix/Linux newline character is '\n',

Mac newline character is ' \r',

In python, newline characters are processed uniformly and defined as "\n".

Use "\" for line break input:

1. In python, Python uses backslash ("\") as the line continuation character ( newline character), here we take python3.5 as an example. First run the terminal or cmd command line (under windows) and execute the python3.5 command.

What is the newline character in Python?

#2. Then enter the content as shown below. It is a string that outputs hello world!. But "" is used here for line breaks.

What is the newline character in Python?

3. This line wrapping method can also be performed in the editor. Here we take vim as an example. Enter code similar to the above picture and save it as a t.py script file. .

What is the newline character in Python?

#4. Execute the following command in bash, it can also be executed.

What is the newline character in Python?

#5. If you do not want to use commands, you can add permissions to the python script. First, specify the script interpreter as python in the script file. Add the following line to the above t.py script file: #!/usr/bin/env python.

What is the newline character in Python?

6. Then execute the following command to add executable permissions to t.py, chmod 755 t.py. Execute the following command to execute the python script, ./t.py, which can also be executed.

What is the newline character in Python?

Recommended tutorial: "python tutorial"

The above is the detailed content of What is the newline character in Python?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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
Previous article:How to download Python?Next article:How to download Python?