Python運行出現語法錯誤:IndentationError | TabError: 縮進錯誤排查

寫了python代碼,肉眼看沒發現縮進錯誤啊,可是運行報縮進錯誤以下:html

C:\Users\Administrator\Desktop>c:\Python34\python.exe dict.py
  File "dict.py", line 18
    continue
           ^
TabError: inconsistent use of tabs and spaces in indentation
C:\Users\Administrator\Desktop>

排錯方法:由於當前用的文本編輯器Notepad++,能夠顯示全部的字符的,在: 視圖 -> 顯示符號 -> 顯示空格與製表符,就能夠明確看到錯誤緣由了!python

緣由:新的Python語法,是不支持的代碼對齊中,混用TAB和空格的。因此出現上述錯誤提示了。bash

解決辦法:請把TAB改成空格便可!編輯器

參考博文:cnblogs.com/heimanba/p/3783022.htmlide

IndentationError.png

相關文章
相關標籤/搜索