網站首頁 學習教育 IT科技 金融知識 旅遊規劃 生活小知識 家鄉美食 養生小知識 健身運動 美容百科 遊戲知識 綜合知識
當前位置:趣知科普吧 > IT科技 > 

indented block|IndentationError:expected an

欄目: IT科技 / 發佈於: / 人氣:1.85W
“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張
Tags:block indented