Problem description:
Compile (well, it should be called "explanation") a python program prompts a special error:
IndentationError: unexpected indent
Problem Analysis: according to the following error message after compilation (after explanation), the "p" of print is an IndentationError: unexpected indent. What does it mean?
Indentation refers to indentation and contraction. Unexpected indent means "p" is an "unexpected" indent. That is to say, the problem here is that "p" is an unexpected indent. By checking the source code, we can see a total of two sentences of code. The first sentence is indeed Indented by a character bit. Based on this, we can infer that we have removed the indentation of this sentence, that is, the top level (the top level of the word suddenly reminds me of the elementary language class). What will happen after I explain it?
Experiment:
Now, the two statements of code are written in the "top level" format. After the explanation, there is no problem.
In order to further prove that "every sentence must be written at the top level", we keep the first code at the top level and indent the second sentence to a single character. . <Strong? Http: www.bkjia.com kf ware vc "target =" _ blank "class =" keylink "> VcD4KPHA + pgltzybzcm9 "http://www.2cto.com/uploadfile/Collfiles/20140515/20140515090701152.jpg" alt = "">
The result shows that the second line is IndentationError and the indentation is incorrect.
So far, we come to the conclusion:
In python, every sentence of code should be written in the top level.