What does the Python language use to indicate the hierarchical relationship of each line of code?

爱喝马黛茶的安东尼
Release: 2019-06-20 16:09:45
Original
19145 people have browsed it

The Python language uses strict "indentation" to indicate the format framework of the program. Indentation refers to the blank space before the beginning of each line of code, which is used to indicate the inclusion and hierarchical relationship between codes.

1 indent = 4 spaces.

What does the Python language use to indicate the hierarchical relationship of each line of code?

Indentation is the only way to indicate the program framework in the Python language. When expressing program meanings such as branches, loops, functions, classes, etc., indentation is used in if, while, for, The complete statement of reserved words such as def and class ends with an English colon (:) and is indented afterwards, indicating the ownership relationship between the subsequent code and the immediately unindented statement.

Related recommendations: "Python Video Tutorial"

Indentation style

Single-layer indentation

What does the Python language use to indicate the hierarchical relationship of each line of code?

Multiple levels of indentation

What does the Python language use to indicate the hierarchical relationship of each line of code?

The above is the detailed content of What does the Python language use to indicate the hierarchical relationship of each line of 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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!