autopep8简介
autopep8是一个开源的命令行工具,它能够将Python代码自动格式化为PEP8风格。autopep8使用pycodestyle工具来决定代码中的哪部分需要被格式化,这能够修复大部分pycodestyle工具中报告的排版问题。autopep8本身也是一个Python语言编写的工具,因此,我们可以直接使用pip进行安装:
# pip install autopep8
# autopep8 --in-place /path/to/optparse.py
'''To modify a file in place (with aggressive level 2):'''
autopep8 --in-place --aggressive --aggressive <filename>
usage: autopep8 [-h] [--version] [-v] [-d] [-i] [--global-config filename]
[--ignore-local-config] [-r] [-j n] [-p n] [-a]
[--experimental] [--exclude globs] [--list-fixes]
[--ignore errors] [--select errors] [--max-line-length n]
[--line-range line line] [--hang-closing] [--exit-code]
[files [files ...]]
Automatica