簡化它的後(最「」是我的程序實際的代碼是全功能):什麼是nonetype?真的不明白
studentName = ""
def getExamPoints (total):
"calculates examPoints here"
def getHomeworkPoints (total):
"calculates hwPoints here"
def getProjectPoints (total):
"calculates projectPoints here"
def computeGrade():
if studentScore>=90:
grade='A'
elif studentScore>=80:
grade='B'
elif studentScore>=70:
grade='C'
elif studentScore>=60:
grade='D'
else:
grade='F'
def main():
classAverage = 0.0 # All below is pre-given/ required code
classAvgGrade = "C"
studentScore = 0.0
classTotal = 0.0
studentCount = 0
gradeReport = "\n\nStudent\tScore\tGrade\n============================\n"
studentName = raw_input ("Enter the next student's name, 'quit' when done: ")
while studentName != "quit":
studentCount = studentCount + 1
examPoints = getExamPoints (studentName)
hwPoints = getHomeworkPoints (studentName)
projectPoints = getProjectPoints (studentName)
studentScore = examPoints + hwPoints + projectPoints #(<---- heres where my problem is!)
studentGrade = computeGrade (studentScore)
main()
它口口聲聲說:
File "/home/hilld5/DenicaHillPP4.py", line 65, in main studentScore = examPoints + hwPoints + projectPoints
TypeError: unsupported operand type(s) for +: 'NoneType' and 'NoneType'
我已經從來沒有學過或聽說過非類型錯誤,即使在使用谷歌搜索時也沒有真正理解。任何認爲他們明白髮生了什麼/知道什麼是nonetype的人?
如果是這樣的代碼,什麼缺少它,所以它retrns「無」:「代碼」高清getExamPoints(總): \t總= 0.0 \t爲i的範圍(4): \t \t examPoints =輸入( 「輸入考試」 + STR第(i + 1)+ 「分數爲」 + studentName + 「:」) \t總+ = INT(examPoints) \t總=總數/ .0 \t \t \t total = total * 100'code' – user2031682 2013-03-01 07:59:55
btw th e nonetype現在完全有意義,謝謝你解釋得非常好 – user2031682 2013-03-01 08:02:02