atom editor indentation error with Python

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 15:34:24

问题


I am new to atom, so I opened my existing code using atom and modified few lines, then when I tried running the code with python, I get the following error:

IndentationError: unindent does not match any outer indentation level

I realized that Atom editor does indent my code differently to what I had. refer to the attached picture below showing the different indentation styles. line 1300 is the old indentation and 1301 is the one created by Atom

How can I fix this without modifying my 1000+ line code and so that atom uses the same style of indentation.


回答1:


You have mixed tabs and spaces in your code. You should use spaces, always.

You can use this plugin to quickly fix your code, and please, use only spaces and 4 spaces for each level of indentation.




回答2:


I had a similar error while using Atom,I fixed it using below steps.

  1. Install notepad++

  2. Open the file which has issue(one you have mentioned in question) in notepad++.

  3. Go to View > Show Symbol > Show All Characters,this will show up where the tabs and where spaces are available.

  4. Go to Edit->Blank Operations->TAB to Space to replace all tabs with spaces.

  5. Go to View > Show Symbol > Show All Characters,confirm all tabs are replaced with spaces.

  6. Save file and reload page,this will fix this issue.



来源:https://stackoverflow.com/questions/24118234/atom-editor-indentation-error-with-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!