Python 日志类型错误 [英] Python logging typeerror

查看:53
本文介绍了Python 日志类型错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你能帮我吗,怎么了.

<前>导入日志if (__name__ == "__main__"):logging.basicConfig(format='[%(asctime)s] %(levelname)s::%(module)s::%(funcName)s() %(message)s', level=logging.DEBUG)logging.INFO("测试")

而且我无法运行它,出现错误:

<前>回溯(最近一次调用最后一次):文件/home/htfuws/Programming/Python/just-kidding/main.py",第 5 行,在logging.INFO("测试")类型错误:int"对象不可调用

非常感谢.

解决方案

logging.INFO 表示一个整数常量,值为 20

<块引用>

INFO 确认事情按预期工作.

您需要的是logging.info

logging.info("test")

Could you please help me, whats wrong.

import logging

if (__name__ == "__main__"):
    logging.basicConfig(format='[%(asctime)s] %(levelname)s::%(module)s::%(funcName)s() %(message)s', level=logging.DEBUG)
    logging.INFO("test")

And I can't run it, I've got an error:

Traceback (most recent call last):
  File "/home/htfuws/Programming/Python/just-kidding/main.py", line 5, in 
    logging.INFO("test")
TypeError: 'int' object is not callable

Thank you very much.

解决方案

logging.INFO denotes an integer constant with value of 20

INFO Confirmation that things are working as expected.

What you need is logging.info

logging.info("test")

这篇关于Python 日志类型错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆