python基礎autopep8__python代碼規範

來源:互聯網
上載者:User

標籤:name   bsp   show   ring   ati   gui   war   tar   err   

關於PEP 8

PEP 8,Style Guide for Python Code,是Python官方推出編碼約定,主要是為了保證 Python 編碼的風格一致,提高代碼的可讀性。

官網地址:https://www.python.org/dev/peps/pep-0008/

關於Autopep8

Autopep8是自動將Python代碼格式化為符合PEP 8風格的工具。它使用pycodestyle工具來確定代碼的哪些部分需要被格式化。Autopep8能夠修複大部分pycodestyle檢測的格式問題。

github地址:https://github.com/hhatto/autopep8

安裝:

pip install autopep8

 

使用命令:

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]>                 [files [files ...]]> > Automatically formats Python code to conform to the PEP 8 style guide.> > positional arguments:>   files                 files to format or ‘-‘ for standard in> > optional arguments:>   -h, --help            show this help message and exit>   --version             show program‘s version number and exit>   -v, --verbose         print verbose messages; multiple -v result in more>                         verbose messages>   -d, --diff            print the diff for the fixed source>   -i, --in-place        make changes to files in place>   --global-config filename>                         path to a global pep8 config file; if this file does>                         not exist then this is ignored (default:>                         ~/.config/pep8)>   --ignore-local-config>                         don‘t look for and apply local config files; if not>                         passed, defaults are updated with any config files in>                         the project‘s root directory>   -r, --recursive       run recursively over directories; must be used with>                         --in-place or --diff>   -j n, --jobs n        number of parallel jobs; match CPU count if value is>                         less than 1>   -p n, --pep8-passes n>                         maximum number of additional pep8 passes (default:>                         infinite)>   -a, --aggressive      enable non-whitespace changes; multiple -a result in>                         more aggressive changes>   --experimental        enable experimental fixes>   --exclude globs       exclude file/directory names that match these comma->                         separated globs>   --list-fixes          list codes for fixes; used by --ignore and --select>   --ignore errors       do not fix these errors/warnings (default: E24)>   --select errors       fix only these errors/warnings (e.g. E4,W)>   --max-line-length n   set maximum allowed line length (default: 79)>   --line-range line line, --range line line>                         only fix errors found within this inclusive range of>                         line numbers (e.g. 1 99); line numbers are indexed at

 

 

python基礎autopep8__python代碼規範

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.