如何修复pylint logging-not-lazy? [英] How to fix pylint logging-not-lazy?
问题描述
我正在使用探矿者检查我的代码.Pylint 返回了关于我的调试消息的 logging-not-lazy
警告.
I am using prospector to examine my code. Pylint returned a logging-not-lazy
warning about my debug message.
Line: 31
pylint: logging-not-lazy / Specify string format arguments as logging function parameters (col 16) Line: 42
pylint: logging-not-lazy / Specify string format arguments as logging function parameters (col 12)
我的代码是:
logging.debug("detect mimetypes faild because %s" % e )
如何修复pylint中的logging-not-lazy
?
How do I fix logging-not-lazy
in pylint?
推荐答案
这意味着,您应该将代码重写为:
This means, that you should rewrite your code as:
logging.debug("detect mimetypes faild because %s", e)
根据 https://docs.python.org/2/library/logging.html
Logger.debug(msg, *args, **kwargs)
... 在这个记录器上记录一个级别为 DEBUG 的消息.msg
是消息格式字符串,args
是使用字符串格式化操作符合并到 msg 中的参数.(注意这个意味着您可以在格式字符串中使用关键字以及单个字典参数.) ...
... Logs a message with level DEBUG on this logger. The msg
is the message format string, and the args
are the arguments which are merged into msg using the string formatting operator. (Note that this means that you can use keywords in the format string, together with a single dictionary argument.) ...
这篇关于如何修复pylint logging-not-lazy?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!