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() 함수의 문제점은 무엇입니까? (인수)없이
의 인스턴스()'당신의 슈퍼 클래스, 난의 이름으로'슈퍼를 교체합니다. 이자형. '자동차 '. 아니면'super'를 원한다면,'super (electricCar, self) .__ init __ (make, model, year)' – BusyAnt
어떤 파이썬 버전을 사용하고 있습니까? [super]() 구문은 [공식 문서] (https://docs.python.org/2/library/functions.html#super)에서 볼 수 있습니다. Python 2의 경우 유형 인수로 하위 클래스 이름을 지정해야합니다. Python3의 경우 – RedBaron
방금 언어를 배우면 6 세 * 인 Python 버전으로 시작하는 이유는 무엇입니까? 최신 버전부터 시작하십시오. Python2는 이전 시스템/라이브러리와의 하위 호환성을 위해 필요한 사용자 만 사용해야합니다. – Bakuriu