问答详情
源自:3-2 Python继承类

代码运行错误

class Person(object):

def __int__(self,name,gender):

self.name = name

self.gender = gender


class Teacher(Person):

def __int__(self,name,gender,course):

super(Teacher,self).__int__(name,gender)

self.course=course

teacher=Teacher('Alice','Female','English')

print(teacher.name)

print(teacher.gender)

print(teacher.course)'''

哪位大声给解释下  粗行  为什么运行有如下错误:

Traceback (most recent call last):

  File "C:\Users\ZF\Desktop\test.py", line 25, in <module>

    teacher=Teacher('Alice','Female','English')

TypeError: Teacher() takes no arguments


提问者:小白兔cai 2021-04-11 23:25

个回答

  • 奶香馒头
    2021-05-28 17:03:12

    http://img2.mukewang.com/60b0b1a900019ee307020652.jpg__init__

  • 小白兔cai
    2021-04-11 23:41:55

    定义函数

     def __init__(self,   ,  ):函数是写成了   def __int__(self,   ,   ):

    改写为   def __init__(self,   ,   ):