小编dat*_*dat的帖子

Python TypeError:object()不带参数错误

我是Python的初学者.我正在关注"以艰难的方式学习Python".在练习40中,我尝试编写一个简短的代码但是出错了.请帮我 :(

资源

class showInfo(object):
    'Initialize a classL'
    def __int__(self, name, phone, age):
        self.name = name
        self.phone = phone
        self.age = age

def showName(self):
    print("Name: "+self.name)
def showAge(self):
    print("Age: "+self.age)
def showPhone(self):
    print("Phone: "+self.phone)

emp1 = showInfo("JJJ")

emp1.showName()
Run Code Online (Sandbox Code Playgroud)

调试

Traceback (most recent call last):
File "classes.py", line 15, in <module>
    emp1 = showInfo("JJJ")
TypeError: object() takes no parameters
Run Code Online (Sandbox Code Playgroud)

python python-3.x

0
推荐指数
1
解决办法
4169
查看次数

标签 统计

python ×1

python-3.x ×1