我在此代码返回时得到的语法无效:
def readDataSet(filename):
fr = open(filename)
numberOfLines = len(fr.readlines())
returnMat = numpy.zeros((numberOfLines-1,3))
classLabelVector = []
classColorVector = []
fr = open(filename)
index = 0
for line in fr.readlines():
if index != 0:
line = line.strip()
listFromLine = line.split('\t')
returnMat[index-1,:] = listFromLine[1:4]
classLabel = listFromLine[4]
if classLabel == "Buero":
color = 'yellow'
elif classLabel == "Wohnung":
color = 'red'
else:
color = 'blue'
classLabelVector.append(classLabel)
classColorVector.append(color)
index += 1
return returnMat,classLabelVector, classColorVector
它表示返回语法错误,但我不知道错误的位置。