IT科技

當前位置 /首頁/IT科技 > /列表

indented block,IndentationError:expected an

“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標籤:indented block #