关闭→
当前位置:科普经验站>IT科技>indented block IndentationError:expected an

indented block IndentationError:expected an

科普经验站 人气:1.99W
“IndentationError:expected an indented block”这个错误呀该怎么解决呢?下面来介绍一下方法。

材料/工具

电脑

方法

首先来翻译一下这个错误。翻译为“缩进错误:期望一个缩进的块”。

IndentationError:expected an indented block

Python最具特色的就是用缩进来写模块,缩进的空白数量是可变的,但是所有代码块语句必须包含相同的缩进空白数量,这个必须严格执行。

IndentationError:expected an indented block 第2张

错误表明,使用的缩进方式不一致,有的是tab键缩进,有的是空格缩进,改为一致即可。

IndentationError:expected an indented block 第3张

因此,在 Python 的代码块中必须使用相同数目的行首缩进空格数。可以在每个缩进层次使用 单个制表符或两个空格或四个空格 , 切记不能混用。

IndentationError:expected an indented block 第4张
TAG标签:#block #indented #