Home  >  Article  >  Backend Development  >  How to cut a long line of code into multiple lines in python

How to cut a long line of code into multiple lines in python

silencement
silencementOriginal
2019-05-23 10:30:2315000browse

How to cut a long line of code into multiple lines in python: 1. You can use backslashes to link multiple lines of code, the syntax is "22 \ 33"; 2. You can use parentheses to link, the syntax is "( 22 33)"; 3. Use three quotation marks to link, the syntax is "'''22 45'''", the three quotation mark method is only useful for strings.

How to cut a long line of code into multiple lines in python

#In the process of writing code, we often encounter situations where a line of code is very long. In order to make the code look neat and clean, you need to divide one line of code into multiple lines to write. There are two tricks in Python to achieve this function:

1. Use backslashes to link multiple lines of code

How to cut a long line of code into multiple lines in python

Example output:

55

2. Surround it with parentheses

How to cut a long line of code into multiple lines in python

Example output:

55

Tip: There is a simple way to write longer strings divided into multiple lines: use three single quotes, but this method is only useful for strings.

How to cut a long line of code into multiple lines in python

The following code output:

32 +
     45

The above is the detailed content of How to cut a long line of code into multiple lines 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