相关疑难解决方法(0)

PyLint消息:logging-format-interpolation

对于以下代码:

logger.debug('message: {}'.format('test'))
Run Code Online (Sandbox Code Playgroud)

pylint 产生以下警告:

记录格式插值(W1202):

在日志记录函数中使用%格式并将%参数作为参数传递当日志语句的调用形式为"logging.(format_string.format(format_args ...))"时使用.此类调用应使用%格式,但通过将参数作为参数传递,将插值留给日志记录功能.

我知道我可以关掉这个警告,但我喜欢理解它.我假设使用format()是打印输出语句的首选方法pylint.为什么记录器语句不适用?

python pylint python-3.x

128
推荐指数
4
解决办法
3万
查看次数

Python:打印变量的名称和值?

在调试时,我们经常会看到如下的print语句:

print x        # easy to type, but no context
print 'x=',x   # more context, harder to type
12
x= 12
Run Code Online (Sandbox Code Playgroud)

如何编写一个函数来获取变量或变量的名称并打印其名称和值?我只对调试输出感兴趣,这不会被合并到生产代码中.

debugPrint(x)    #  or
debugPrint('x')
x=12
Run Code Online (Sandbox Code Playgroud)

python debugging

36
推荐指数
5
解决办法
3万
查看次数

标签 统计

python ×2

debugging ×1

pylint ×1

python-3.x ×1