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

What does the python language use strictly?

Release: 2019-07-08 09:10:38
Original
10480 people have browsed it

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")//
Copy after login

Output result:

this is true
this is true
Copy after login

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!

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