环境:win10(64),python3.7.1,git2.7.2,pylint-2.3.1,git_pylint_commit_hook-2.5.1
以上为当期搭建所用到的版本,有异常时方便查找问题。
安装pylint,pylint是一个单独可以对python文件进行格式校验的模块,https://www.pylint.org/ 官网地址有各个电脑环境的安装说明,Windows下,使用:
pip install pylint
安装完成之后,就可以直接使用pylint对python文件进行格式的检查了,要检查的文件如下:
print("啦啦啦")
def func():
print("do something special")
def func1():
print("sdfsd")
执行结果如下:
$ pylint test1.py
************* Module test1
test1.py:1:0: C0111: Missing module docstring (missing-docstring)
test1.py:2:0: C0111: Missing function docstring (missing-docstring)
test1.py:5:0: C0111: Missing function docstring (missing-docstring)
------------------------------------------------------------------
Your code has been rated at 4.00/10 (previous run: 4.00/10, +0.00)
修改后满分代码:
"""模块说明"""
print("啦啦啦")
def func():
"""func函数说明"""
print("do something special")
def func1():
"""func1函数说明"