Python语言规范之Pylint的详细用法


Posted in Python onJune 24, 2021

1、Pylint是什么

pylint是一个Python源代码中查找bug的工具,能找出错误,和代码规范的运行。也就是你的代码有Error错误的时候能找出来错误,没有错误的时候,能根据Python代码规范给你建议修改代码,让代码变更美观。

2、安装pylint

pip3 install pylint

3、查找pylint的安装地址

$ which pylint
/Library/Frameworks/Python.framework/Versions/3.9/bin/pylint

4、Pycharm使用Pylint工具

1)Pycharm --> Preferences --> Tools --> External Tools --> +

Python语言规范之Pylint的详细用法

Program:pylint的地址,可以通过which pylint找到地址Arguments:pylint运行的参数2)使用

Python语言规范之Pylint的详细用法

3)得到的结果

************* Module 704
leetcode/704.py:28:0: C0305: Trailing newlines (trailing-newlines)         #文尾有多余的行
leetcode/704.py:1:0: C0114: Missing module docstring (missing-module-docstring)  # 脚本首行没有添加注释
leetcode/704.py:4:11: W0621: Redefining name 'nums' from outer scope (line 23) (redefined-outer-name)  #变量名字与函数参数名字不能一样
leetcode/704.py:4:28: W0621: Redefining name 'target' from outer scope (line 24) (redefined-outer-name) #变量名字与函数参数名字不能一样
leetcode/704.py:4:0: C0116: Missing function or method docstring (missing-function-docstring)  #函数缺少注释,注释要放在函数的第一行而不是def的上面

5、pylint的5种信息类型

Output:
   Using the default text output, the message format is :
  MESSAGE_TYPE: LINE_NUM:[OBJECT:] MESSAGE
  There are 5 kind of message types :
  * (C) convention, for programming standard violation
  * (R) refactor, for bad code smell
  * (W) warning, for python specific problems
  * (E) error, for probable bugs in the code
  * (F) fatal, if an error occurred which prevented pylint from doing further processing.

* (C) 约定,用于违反编程标准

* (R) 重构,针对糟糕的代码味道

* (W) 警告,针对 python 特定问题

* (E) 错误,用于代码中可能的错误

* (F) 致命的,如果发生错误导致 pylint 无法进行进一步处理。

6、更多的pylint信息

1)可以通过命令行获取

pylint --list-msgs

2)官网

http://pylint.pycqa.org/en/latest/

以上就是Python语言规范之Pylint的使用的详细内容,更多关于Python Pylint的使用的资料请关注三水点靠木其它相关文章!

Python 相关文章推荐
python二叉树的实现实例
Nov 21 Python
利用打码兔和超人打码自封装的打码类分享
Mar 16 Python
Python中的下划线详解
Jun 24 Python
Python装饰器实现几类验证功能做法实例
May 18 Python
Python 3.6 读取并操作文件内容的实例
Apr 23 Python
python的re模块使用方法详解
Jul 26 Python
TensorFlow2.X结合OpenCV 实现手势识别功能
Apr 08 Python
使用python matplotlib 画图导入到word中如何保证分辨率
Apr 16 Python
浅谈django 重载str 方法
May 19 Python
Python xlrd模块导入过程及常用操作
Jun 10 Python
python实现从ftp上下载文件的实例方法
Jul 19 Python
Python Django框架介绍之模板标签及模板的继承
May 27 Python
Python基础教程,Python入门教程(超详细)
Jun 24 #Python
Django Paginator分页器的使用示例
python随机打印成绩排名表
教你怎么用Python selenium操作浏览器对象的基础API
Jun 23 #Python
Python一些基本的图像操作和处理总结
Python使用openpyxl批量处理数据
浅谈Python实现opencv之图片色素的数值运算和逻辑运算
You might like
PHP 批量删除数据的方法分析
2009/10/30 PHP
ThinkPHP3.1查询语言详解
2014/06/19 PHP
php array_walk_recursive 使用自定的函数处理数组中的每一个元素
2016/11/16 PHP
php 使用curl模拟ip和来源进行访问的实现方法
2017/05/02 PHP
jQuery+slidereveal实现的面板滑动侧边展出效果
2015/03/14 Javascript
JavaScript基础知识之方法汇总结
2016/01/24 Javascript
jQuery AjaxUpload 上传图片代码
2016/02/02 Javascript
浅谈jquery拼接字符串效率比较高的方法
2017/02/22 Javascript
浅谈Node框架接入ELK实践总结
2019/02/22 Javascript
微信小程序实现判断是分享到群还是个人功能示例
2019/05/03 Javascript
Angular2使用SVG自定义图表(条形图、折线图)组件示例
2019/05/10 Javascript
JavaScript多种滤镜算法实现代码实例
2019/12/10 Javascript
Js视频播放器插件Video.js使用方法详解
2020/02/04 Javascript
详解VUE中的插值( Interpolation)语法
2020/10/18 Javascript
解决vue项目axios每次请求session不一致的问题
2020/10/24 Javascript
Python greenlet实现原理和使用示例
2014/09/24 Python
python条件变量之生产者与消费者操作实例分析
2017/03/22 Python
K-近邻算法的python实现代码分享
2017/12/09 Python
程序员写Python时的5个坏习惯,你有几条?
2018/11/26 Python
Python3实现对列表按元组指定列进行排序的方法分析
2018/12/22 Python
Python离线安装PIL 模块的方法
2019/01/08 Python
在Python中os.fork()产生子进程的例子
2019/08/08 Python
django rest framework使用django-filter用法
2020/07/15 Python
Django中使用Celery的方法步骤
2020/12/07 Python
CSS3教程:新增加的结构伪类
2009/04/02 HTML / CSS
CSS3 优势以及网页设计师如何使用CSS3技术
2009/07/29 HTML / CSS
html5中监听canvas内部元素点击事件的三种方法
2019/04/28 HTML / CSS
美国女孩洋娃娃店:American Girl
2017/10/24 全球购物
师范生实习自我鉴定
2013/11/01 职场文书
公司财务自我评价分享
2013/12/17 职场文书
公司文体活动总结
2015/05/07 职场文书
2016新年致辞
2015/08/01 职场文书
计算机教师工作总结
2015/08/13 职场文书
python必学知识之文件操作(建议收藏)
2021/05/30 Python
经典《舰娘》游改全新动画预告 预定11月开播
2022/04/01 日漫
苹果的回收机器人可以通过拆解iPhone获取大量的金和铜并外公布了环境保护最新进展
2022/04/21 数码科技