Python語(yǔ)言規(guī)范之Pylint的詳細(xì)用法
pylint是一個(gè)Python源代碼中查找bug的工具,能找出錯(cuò)誤,和代碼規(guī)范的運(yùn)行。也就是你的代碼有Error錯(cuò)誤的時(shí)候能找出來(lái)錯(cuò)誤,沒(méi)有錯(cuò)誤的時(shí)候,能根據(jù)Python代碼規(guī)范給你建議修改代碼,讓代碼變更美觀。
2、安裝pylintpip3 install pylint3、查找pylint的安裝地址
$ which pylint/Library/Frameworks/Python.framework/Versions/3.9/bin/pylint4、Pycharm使用Pylint工具
1)Pycharm --> Preferences --> Tools --> External Tools --> +
Program:pylint的地址,可以通過(guò)which pylint找到地址Arguments:pylint運(yùn)行的參數(shù)2)使用
3)得到的結(jié)果
************* Module 704leetcode/704.py:28:0: C0305: Trailing newlines (trailing-newlines) #文尾有多余的行l(wèi)eetcode/704.py:1:0: C0114: Missing module docstring (missing-module-docstring) # 腳本首行沒(méi)有添加注釋leetcode/704.py:4:11: W0621: Redefining name ’nums’ from outer scope (line 23) (redefined-outer-name) #變量名字與函數(shù)參數(shù)名字不能一樣leetcode/704.py:4:28: W0621: Redefining name ’target’ from outer scope (line 24) (redefined-outer-name) #變量名字與函數(shù)參數(shù)名字不能一樣leetcode/704.py:4:0: C0116: Missing function or method docstring (missing-function-docstring) #函數(shù)缺少注釋?zhuān)⑨屢旁诤瘮?shù)的第一行而不是def的上面5、pylint的5種信息類(lèi)型
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) 約定,用于違反編程標(biāo)準(zhǔn)
* (R) 重構(gòu),針對(duì)糟糕的代碼味道
* (W) 警告,針對(duì) python 特定問(wèn)題
* (E) 錯(cuò)誤,用于代碼中可能的錯(cuò)誤
* (F) 致命的,如果發(fā)生錯(cuò)誤導(dǎo)致 pylint 無(wú)法進(jìn)行進(jìn)一步處理。
6、更多的pylint信息1)可以通過(guò)命令行獲取
pylint --list-msgs
2)官網(wǎng)
http://pylint.pycqa.org/en/latest/#
以上就是Python語(yǔ)言規(guī)范之Pylint的使用的詳細(xì)內(nèi)容,更多關(guān)于Python Pylint的使用的資料請(qǐng)關(guān)注好吧啦網(wǎng)其它相關(guān)文章!
相關(guān)文章:
1. ASP常用日期格式化函數(shù) FormatDate()2. Python 操作 MySQL數(shù)據(jù)庫(kù)3. Python數(shù)據(jù)相關(guān)系數(shù)矩陣和熱力圖輕松實(shí)現(xiàn)教程4. 開(kāi)發(fā)效率翻倍的Web API使用技巧5. bootstrap select2 動(dòng)態(tài)從后臺(tái)Ajax動(dòng)態(tài)獲取數(shù)據(jù)的代碼6. CSS3中Transition屬性詳解以及示例分享7. js select支持手動(dòng)輸入功能實(shí)現(xiàn)代碼8. 什么是Python變量作用域9. vue使用moment如何將時(shí)間戳轉(zhuǎn)為標(biāo)準(zhǔn)日期時(shí)間格式10. python 如何在 Matplotlib 中繪制垂直線
