Home >Backend Development >Python Tutorial >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!