python新手
使用python3.X
不知道如何解决
class Car():
def __int__(self,make,model,year):
self.make=make
self.model=model
self.year=year
class ElectricCar(Car):
def __init__(self,make,model,year):
super().__init__(make,model,year)
my_tesla =ElectricCar('tesla','model s',2016)
#TypeError: object.__init__() takes no parameters
答案 0 :(得分:0)
你在Car.init()中拼错了init。它是__init__()
而非init()
试试这个:
class Car():
def __init__(self,make,model,year):
self.make=make
self.model=model
self.year=year
class ElectricCar(Car):
def __init__(self,make,model,year):
super().__init__(make,model,year)
my_tesla =ElectricCar('tesla','model s',2016)