PyCharm出現TabError: inconsistent use of tabs and spaces in indentation最簡單實用的解決辦法


本文使用PyCharm的格式化代碼功能解決TabError: inconsistent use of tabs and spaces in indentation。

當把代碼從別處復制進來PyCharm,然后運行報錯:TabError: inconsistent use of tabs and spaces in indentation

這個報錯的意思是說IDE分不清tab和空格,說明你的代碼中混用了tab和空格。

傳統的方式是找出代碼中報錯的地方,然后修改。

這種方法可以,但是我試的並不好用。我推薦一種解決方法:格式化代碼

具體操作是:Code -->Reformat Code

再次嘗試運行,問題完美解決!

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM