class car(object):
def __init__(self, make, model, year):
self.make = make
self.model = model
self.year = year
self.odometer_reading = 0
class electricCar(car):
def __init__(self, make, model, year):
super().__init__(make, model, year)
tesla = electricCar('tesla', 'model s', 2016)
print tesla.get_descriptive_name()
TypeError: super() takes at least 1 argument (0 given)python super()函数错误?
super()函数有什么问题?
用你的超类名称i替换'super()'。即'car'。或者如果你想'super','super(electricCar,self).__ init __(make,model,year)' – BusyAnt
你使用的是什么版本的Python?你可以在[官方文档](https://docs.python.org/2/library/functions.html#super)中看到'super()'语法。对于Python 2,您需要指定子类名称作为类型参数。对于Python3,你不需要 – RedBaron
如果你只是在学习语言......你为什么从一个* 6岁*的Python版本开始?刚开始使用最新版本。 Python2只能由需要它的用户使用,以便与旧系统/库向后兼容。 – Bakuriu