當前位置:生活全書館 >

IT科技

> indented block IndentationError:expected an

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張
標籤: block indented
  • 文章版權屬於文章作者所有,轉載請註明 https://shqsg.com/dianzi/32rz9.html