问题
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