Python Formatter Tool

大憨熊 提交于 2019-11-28 17:28:55

问题


I was wondering if there exists a sort of Python beautifier like the gnu-indent command line tool for C code. Of course indentation is not the point in Python since it is programmer's responsibility but I wish to get my code written in a perfectly homogenous way, taking care particularly of having always identical blank space between operands or after and before separators and between blocks.


回答1:


I am the one who asks the question. In fact, the tool the closest to my needs seems to be PythonTidy (it's a Python program of course : Python is best served by himself ;) ).




回答2:


autopep8 attempts to automate making your code conform to pep8 coding standards

https://pypi.python.org/pypi/autopep8




回答3:


You can also try yapf:

A formatter for Python files

https://github.com/google/yapf/




回答4:


PyLint has some formatting checks.




回答5:


Have you looked at pindent?



来源:https://stackoverflow.com/questions/1032393/python-formatter-tool

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