Home > Backend Development > Python Tutorial > 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
Release: 2020-09-18 14:40:09
Original
15082 people have browsed it

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
Copy after login

2. Surround it with parentheses

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

Example output:

55
Copy after login

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
Copy after login

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!

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