【发布时间】:2021-06-01 15:49:34
【问题描述】:
描述代码和错误如下:
代码-
#Inheritance
class Father:
def __init__(self,home):
self.home = home
class Son(Father):
def __init__(self,wife,bike):
super(). __init__(self,home)
self.wife = wife
self.bike = bike
sonworth = Son("fourbhk","nikita","hayabusa")
print(sonworth.home,sonworth.wife,sonworth.bike)
错误 -
TypeError Traceback (most recent call last)
<ipython-input-69-b4fa474bd6de> in <module>
10 self.bike = bike
11
---> 12 sonworth = Son("fourbhk","nikita","hayabusa")
13 print(sonworth.home,sonworth.wife,sonworth.bike)
14
TypeError: __init__() takes 3 positional arguments but 4 were given
【问题讨论】:
标签: python class oop inheritance