Python에서 상속을 사용하고 있지만 오류가 발생합니다. 수정 방법을 모르므로 'finalStore'객체에 'marone'속성이 없습니다. . 나는 객체를 만들려고 할 때 이것을 얻는다.Python 오류 : 'finalStore'객체에 'name'속성이 없습니다.
from ClassFile import studStore
class finalStore (studStore):
grandAve = 0
numStu = 0
def __init__(self, name, marone, martwo, marthree, marfour, corone, cortwo, corthree, corfour):
studStore.__init__(self, name, marone, martwo, marthree, marfour)
self.corone = corone
self.cortwo = cortwo
self.corthree = corthree
self.corfour = corfour
finalStore.numStu += 1
self.holder = finalStore.numStu
self.average = (marone + martwo + marthree + marfour)/4
finalStore.grandAve += self.average
self.storit = finalStore.grandAve
내 자식 클래스
class studStore:
def __init__(self, name, marone, martwo, marthree, marfour):
self.newname = name
self.Ave = 0
self.marone = marone
self.martwo = martwo
self.marthree = marthree
self.marfour = marfour
에 대한 초기화 그리고 상위 클래스의 초기화. 난 그냥 아니에요, 나는 오류가 무엇인지 확실하지 않다
listIn.append(finalStore(name, gradeone, gradetwo, gradethree, gradefour, courseOne, courseTwo, courseThree, courseFour))
하지만 작동하는 유사한 프로그램을 가지고 내 주요 라인은 내가이 라인에 있지만, 오류에 대한 여러 개체를 만들 단지 루프
내가 슈퍼 클래스의 초기화 기능이
for i in range (0,len(listIn)):
print(str(listIn[i].returnName()).ljust(20," "), end = " ")
print(str(listIn[i].returnOne()).ljust(20, " "))
print(str(listIn[i].returnTwo()).ljust(20, " "))
print(str(listIn[i].returnThree()).ljust(20, " "))
print(str(listIn[i].returnFour()).ljust(20, " "))
오류의 실제 출력을 게시 할 수 있습니까? – Haz
"finalStore"개체에 "marone"속성이 없습니다. –
스택 추적 또는 콘솔에 인쇄되고있는 것이 없습니까? 있다면, 귀하의 게시물에 추가해야합니다. – Haz