+-
python – 如何修复pylint logging-not-lazy?
参见英文答案 > PyLint message: logging-format-interpolation                                    1个
我正在使用prospector来检查我的代码. Pylint返回了一个关于我的调试消息的日志记录而不是懒惰的警告.

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?

最佳答案
这意味着,您应该将代码重写为:

logging.debug("detect mimetypes faild because %s", e)

根据https://docs.python.org/2/library/logging.html

Logger.debug(msg, *args, **kwargs)

… 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.) …

点击查看更多相关文章

转载注明原文:python – 如何修复pylint logging-not-lazy? - 乐贴网