在下面的代码块中
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),没有警告/语法错误。只在蟒蛇壳里..。
ipython中的UPDATE看起来很像%cpaste (或%),它修复了这个问题。
发布于 2015-02-19 01:24:55
看起来,ipython中的%c粘贴(或%粘贴)修复了这个问题。
https://stackoverflow.com/questions/28575384
复制相似问题