How to fix Python indentation

前端 未结 13 1448
梦毁少年i
梦毁少年i 2020-11-22 08:17

I have some Python code that have inconsistent indentation. There is a lot of mixture of tabs and spaces to make the matter even worse, and even space indentation is not pre

13条回答
  •  迷失自我
    2020-11-22 08:49

    Use the reindent.py script that you find in the Tools/scripts/ directory of your Python installation:

    Change Python (.py) files to use 4-space indents and no hard tab characters. Also trim excess spaces and tabs from ends of lines, and remove empty lines at the end of files. Also ensure the last line ends with a newline.

    Have a look at that script for detailed usage instructions.

提交回复
热议问题