Home  >  Article  >  Backend Development  >  What does the python language use strictly?

What does the python language use strictly?

尚
Original
2019-06-28 10:23:5810374browse

What does the python language use strictly?

The Python language uses strict "indentation" to represent 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 space indentation = 4 spaces

Indentation is the only way to indicate the program framework in the Python language.

Python’s indentation method:

Use the tab key

Indent a few spaces (usually 4)

For example, the following example:

>>> if True:
…… print("this is true") //
…… print("this is true") //
…… else:
…… print("this is false")//
…… print("this is false")//

Output result:

this is true
this is true

It should be noted that although Python syntax allows code blocks to be indented by any number of spaces, all statements located in the same code block must maintain the same indentation. , you cannot indent 3 spaces at a time or 4 spaces at a time.

For more Python related technical articles, please visit the Python Tutorial column to learn!

The above is the detailed content of What does the python language use strictly?. 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