Home >Backend Development >Python Tutorial >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.
Then enter the content as shown below. It is a string that outputs hello world!. But "\" is used here for line breaks.
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.
Execute the following command in bash, it can also be executed.
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.
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!