TypeError: object() takes no parameters
TypeError: object() takes no parameters
TypeError: object() takes no parameters
TypeError: object() takes no parameters
TypeError: object() takes no parameters
2015-04-10
我 这段代码也出现了TypeError: object() takes no parameters 这样的问题,能帮我看看么?
import Levenshtein
import pylab
class LabelSet(object):
def __int__(self,labelName):
self.labelName = labelName
def getLabelName(self):
return self.labelName
def distance(self,other):
return Levenshtein.distance(self.labelName,other.labelName)
def compareLabels(labels,precision):
columnLabels = []
for a in labels:
columnLabels.append(a.getLabelName())
rowLabels = columnLabels[:]
tableVals = []
for a1 in labels:
row =[]
for a2 in labels:
if a1==a2:
row.append('--')
else:
distance = a1.distance(a2)
row.append(str(round(distance,precision)))
tableVals.append(row)
table = pylab.table(rowLabels = rowLabels,
colLabels = columnLabels,
cellText = tableVals,
cellLoc = 'center',
loc = 'center',
colWidths = [0.2]*len(labels))
table.scale(1,2.5)
pylab.axis('off')
pylab.savefig('distance')
classic = LabelSet('classic')
R = LabelSet('R')
comedy = LabelSet('comedy')
action = LabelSet('action')
dvd = LabelSet('dvd')
owned = LabelSet('owned')
labels=[classic,R,comedy,action,dvd,owned]
compareLabels(labels,3)
举报