在下面的代码块中
def classify0(inx, ds, ls, k):
sizeds = ds.shape[0]
dmat = tile(inx, (sizeds, 1)) -ds
sdmat = dmat**2
sqdist = sdmat.sum(axis=1)
dist = sqdist**2
sdindices = dist.argsort()
clcount = {}
for i in range(k):
vlab = ls[sdindices[i]]
clcount[vlab] = clcount.get(vlab,0)+1
sclcount = sorted(clcount.iteritems(), key=operator.itemgetter(1), reverse=True)
# Previous lines gives: IndentationError: unindent does not match any outer indentation level
return sclcount[0][0]
如注释所示,以
sclcount = "
给出缩进误差:
sclcount = sorted(clcount.iteritems(), key=operator.itemgetter(1), reverse=True)
^
IndentationError: unindent does not match any outer indentation level
现在我检查了所有的“常见嫌疑犯”:没有制表符和正确的空格。你知道吗
另外,我使用的是PyCharm(/intellij),没有警告/语法错误。只在python shell中。。你知道吗
更新看起来像ipython中的%cpaste(或%paste)修复了该问题。你知道吗
看起来ipython中的%cpaste(或%paste)修复了该问题。你知道吗
相关问题 更多 >
编程相关推荐