Home > Backend Development > Python Tutorial > How to change the line in python and continue writing the script

How to change the line in python and continue writing the script

Release: 2020-01-16 10:39:30
Original
13100 people have browsed it

How to change the line in python and continue writing the script

Recommended manual:Python basic introductory tutorial

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

How to change the line in python and continue writing the script

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

How to change the line in python and continue writing the script

This newline 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.

How to change the line in python and continue writing the script

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

How to change the line in python and continue writing the script

Special cases: In the python language, it is completely possible not to use "\" for line breaks in expressions in parentheses, square brackets or curly brackets. Of course, it is also possible. use. For example, the code shown below. is the calculation of a simple arithmetic expression. At this time, you don't need to use "\" to wrap the expression in parentheses, just press Enter to wrap automatically.

How to change the line in python and continue writing the script

Recommended related articles:
1.How to wrap python using cmd
2.How to wrap lines when writing python
Related video recommendations:
1.Little Turtle’s zero-based entry learning Python video tutorial

For more Python-related technical articles, please visit the Python Tutorial column to learn!

The above is the detailed content of How to change the line in python and continue writing the script. 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