Home  >  Article  >  Backend Development  >  What does the Python language use to indicate the hierarchical relationship of each line of code?

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

爱喝马黛茶的安东尼
爱喝马黛茶的安东尼Original
2019-06-20 16:09:4519100browse

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!

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