Home > Backend Development > Python Tutorial > How to enter new lines in python code?

How to enter new lines in python code?

little bottle
Release: 2019-05-21 09:57:19
Original
9850 people have browsed it

Python is a computer scripting language. Its language is concise and clear, and its implementation is also very simple. But sometimes it is not convenient to do it if you are not very familiar with the writing style. The editor below will teach you how to wrap lines when entering Python statements.

How to enter new lines in python code?

Some friends may think, wouldn’t it be enough to just enter?

But in fact it is not that simple. Sometimes in different editors, just enter to start running the code and display the results.

We can use Python to use backslash ("\") as the line continuation character (line break character):

#1. When a command uses continuation When split into multiple lines by the line character ("\"), subsequent lines can be indented in any way, and Python's usual strict indentation rules do not need to be followed.

If your Python IDE freely indents subsequent lines, you should treat it as the default unless you have a specific reason not to do so.

2. Strictly speaking, expressions enclosed in parentheses, square brackets or curly brackets (for example, defining a dictionary) can be split into multiple lines with or without the line continuation character ("\").

You can use line continuation characters even when they are not necessary, which can make the code easier to read. Using line continuation characters is just a matter of style.

The above is the detailed content of How to enter new lines in python code?. 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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template