简体   繁体   English

TypeError:“ int”对象在Python 3中不可调用

[英]TypeError: 'int' object is not callable in Python 3

I am getting TypeError: 'int' object is not callable after passing an object to my class with appropriate arguments. 我收到TypeError:将带有适当参数的对象传递给我的类后, 无法调用“ int”对象

Is this an issue with logging or class? 这是日志记录或类的问题吗? Can Anyone help me with this? 谁能帮我这个?

Following is the Snippet: 以下是代码段:

import logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s-%(message)s')

class employee:

    def __init__(self,first,last):
        self.first=first
        self.last=last

        logging.INFO('Employee created: {} - {} '.format(self.fullname, self.email))

    @property
    def email(self):
        return '{}.{}@email.com'.format(self.first,self.last)
    @property
    def fullname(self):
        return '{} {}'.format(self.first,self.last)

emp_1=employee('John','Doe')
emp_2=employee('John','Smith')

logging.INFO is a numeric value representing a logging level, it is actually the int 20 . logging.INFO是代表日志记录级别的数值,它实际上是int 20

The method to log an INFO message is logging.info , notice the lowercase. 记录INFO消息的方法是logging.info ,请注意小写。

logging.info(msg)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM