小白兔cai
2021-04-11 23:25
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
__init__
定义函数
def __init__(self, , ):函数是写成了 def __int__(self, , ):
改写为 def __init__(self, , ):
Python3 进阶教程(新版)
41910 学习 · 236 问题
相似问题