首页 技术 正文
技术 2022年11月16日
0 收藏 520 点赞 4,183 浏览 2005 个字

关于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开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,491
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,907
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,740
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,493
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,132
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,294