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

20 lines
550 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 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}}`