Home  >  Article  >  Backend Development  >  What is python newline character?

What is python newline character?

藏色散人
藏色散人Original
2020-03-09 11:04:0221474browse

What is python newline character?

What is the python newline character?

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.

Recommended: "Python Tutorial"

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 python newline character?

#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 python newline character?

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 python newline character?

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

What is python newline character?

#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 python newline character?

#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 python newline character?

The above is the detailed content of What is python newline character?. 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