The Python language is a language that is very sensitive to indentation, confusing to many beginners, and even a very experienced Python programmer can be caught in a trap. The most common scenario is that the mix of tab and space results in an error, or indentation is incorrect, which is not possible with the naked eye.
This error will occur at compile time indentationerror:expected an indented block indicates that indentation is required here, as long as you press space or tab (but not mix) to indent the line in the wrong line.
Often some people will question: I do not indent how or wrong, the indentation of the place will be indented, non-indentation will be wrong, such as:
Mode one:
#coding: Utf-8
money=["Zhang Total", "Wang Total", "Li Total", "Liu Manager", "Cleaning Wu Aunt", "Programmer's Me"]
For Mans in Money:
Print Mans
Print Len (Money)
Operation Result:
D:\pf\python> Python test.py
File "test.py", line 7
Print Mans
^
Indentationerror:expected an indented block
Mode two:
#coding: Utf-8
money=["Zhang Total", "Wang Total", "Li Total", "Liu Manager", "Cleaning Wu Aunt", "Programmer's Me"]
For Mans in Money:
Print Mans
Print Len (Money)
Run results
D:\pf\python> Python test.py
Briefly
6
General Wang
6
Cfic
6
Manager Liu
6
Cleaning Wu Aunt
6
Programmer's Me
6
Mode three:
#coding: Utf-8
money=["Zhang Total", "Wang Total", "Li Total", "Liu Manager", "Cleaning Wu Aunt", "Programmer's Me"]
For Mans in Money:
Print Mans
Print Len (Money)
Operation Result:
D:\pf\python> Python test.py
Briefly
General Wang
Cfic
Manager Liu
Cleaning Wu Aunt
Programmer's Me
6
This article is from the "Clear" blog, please be sure to keep this source http://chebgming001.blog.51cto.com/7935897/1685275
Python learning: indentationerror:expected an indented block error resolution