亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

TypeError: object() takes no parameters

TypeError: object() takes no parameters


TypeError:?object()?takes?no?parameters


正在回答

3 回答

__init__函數寫錯成__int__了

0 回復 有任何疑惑可以回復我~

我 這段代碼也出現了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)


0 回復 有任何疑惑可以回復我~
#1

qq_鴻語_0

以上問題,說聲明的參數和實參之間有差異,應該怎么解決呢?
2015-10-20 回復 有任何疑惑可以回復我~
#2

月滿軒尼詩

def __int__(self,labelName):
2017-08-07 回復 有任何疑惑可以回復我~

能否列出問題的代碼?

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
python進階
  • 參與學習       255563    人
  • 解答問題       3038    個

學習函數式、模塊和面向對象編程,掌握Python高級程序設計

進入課程

TypeError: object() takes no parameters

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號