Files
tldr/pages.zh/common/autopep8.md

550 B
Raw Permalink Blame History

autopep8

按照 PEP 8 风格指南格式化 Python 代码。 更多信息:https://github.com/hhatto/autopep8

  • 将文件格式化为 stdout,并设置自定义的最大行长度:

autopep8 {{path/to/file.py}} --max-line-length {{length}}

  • 格式化文件,并显示更改的 diff

autopep8 --diff {{path/to/file}}

  • 就地格式化文件并保存更改:

autopep8 --in-place {{path/to/file.py}}

  • 递归地格式化目录中的所有文件并保存更改:

autopep8 --in-place --recursive {{path/to/directory}}