IndentationError: expected an indented block
作者:互联网
Python使用for循环遍历列表
代码:
fruits=['apple','pear','grape','mango','lemon'] for fruit in fruits : print(fruit)
错误:
IndentationError: expected an indented block #期望一个缩进的块
原因:
在c语言和Java中都是用花括号{ }来区分一个块的,而在python中是用缩进来识别语法逻辑块,类似的有if、while等
纠正:
fruits=['apple','pear','grape','mango','lemon'] for fruit in fruits : print(fruit)
在sublime中使用Tab即可快速缩进
标签:grape,apple,pear,print,fruit,fruits,expected,IndentationError,block 来源: https://www.cnblogs.com/-lemon/p/12373661.html