python 代码规范工具_python代码规范化工具yapf

yapf

yapf是一个Python文件代码格式化工具,通过 YAPF 优化后,代码风格可统一,在每次代码审查中,也就没有必要争论风格了。

用法

usage: yapf [-h] [-v] [-d | -i] [-r | -l START-END] [-e PATTERN]

[--style STYLE] [--style-help] [--no-local-style] [--verify]

[files [files ...]]

Formatter for Python code.

positional arguments:

files

optional arguments:

-h, --help show this help message and exit

-v, --version show version number and exit

-d, --diff print the diff for the fixed source

-i, --in-place make changes to files in place

-r, --recursive run recursively over directories

-l START-END, --lines START-END

range of lines to reformat, one-based

-e PATTERN, --exclude PATTERN

patterns for files to exclude from formatting

--style STYLE specify formatting style: either a style name (for

example "pep8" or "google"), or the name of a file

with style settings. The default is pep8 unless a

.style.yapf or setup.cfg file located in one of the

parent directories of the source file (or current

directory for stdin)

--style-help show style settings and exit

--no-local-style don't search for local style definition

--verify try to verify reformatted code for syntax errors

举例

仅仅查看需要优化的地方yapf -d hello.py

直接格式化代码yapf -i hello.py

来源:oschina

链接:https://my.oschina.net/u/2351685/blog/602684

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值