auto-fix python indentation error [duplicate]

倖福魔咒の 提交于 2019-12-24 02:17:24

问题


Possible Duplicate:
HOWTO: Fix Python Indentation

I have some code that is copy-pasted from older code, so the indentation is completely wrong now, and compiler gives errors.

Is there a way to automatically fix the indentation (not just swapping tabs with spaces)? I tried pyDev 2.7 (which claims to have auto-format) in Eclipse using Ctrl+Shift+F, but it didn't change anything.


回答1:


use reindent

http://pypi.python.org/pypi/Reindent/0.1.0

pip install reindent
reindent <file>

You can also look at PythonTiddy



来源:https://stackoverflow.com/questions/13806961/auto-fix-python-indentation-error

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