我不明白這個問題的含義或如何解決它! 我不斷收到問題AttributeError:'list'對象沒有屬性'assignmentScores' 這是什麼意思?我該如何解決這個問題?AttributeError:'list'對象沒有屬性'assignmentScores'
我的代碼是:
class Student:
studentName = ""
studentCourse = ""
averageMark = 0
grade = "none"
assignmentScores = [1, 2, 3, 4]
def __init__(self, n, c, a, g,m):
self.studentName = n
self.studentCourse = c
self.averageMark = a
self.grade = g
self.assignmentScores = m
def getName(self):
return self.studentName
def getCourse(self):
return self.studentCourse
def getAverage(self):
return self.averageMark
def getGrade(self):
return self.grade
def getMarks(self):
return self.assignmentScores
def setAverage(self):
mark = self.averageMark
return mark
def setGrade(self):
grade = self.grade
return grade
def setMarks(self):
marks = self.setMarks()
return marks
def addMark(self):
score = list.append(self, self.assignmentScores)
def calculateAverage(self):
if len(self.assignmentScores) > 0:
average = sum(self)/float(len(self.assignmentScores))
return average
else:
return 0
def determineGrade(self):
return 0
print(calculateAverage(assignmentScores))
縮進人,請等我先編輯它 – ZdaR
歡迎來到StackOverflow,Oliver。大多數pythonistas對於縮進都很無聊,請修復它。 –
'score = list.append(self,self.assignmentScores)'可以解釋這個語句做了什麼? –