当缩进完全正确时,'IndentationError:unindent与任何外部缩进级别都不匹配'

时间:2015-03-28 17:08:42

标签: python-3.x indentation

我不确切地知道这是一个错误,还是我的编辑错误,但在特定的一行,它总是会引发一个' IndentationError:unindent ......'
我的代码是:

def tokType(token):
    if type(token) is str:
        if ":" in token:
            out = ""
            for c in token:
                if c == ":":
                    break
                out += c
            return out
        else:
            return None
    elif type(token) is list:
        for i, t in enumerate(token):
            if i != 0 and tokType(t) != tokType(token[i-1]):
                return "multi"
        return tokType(token[0])
    else:
        raise TypeError("Unsupported type {0}, expecting List or String!".format(type(token)))

为什么我收到此错误?

1 个答案:

答案 0 :(得分:0)

这是编辑错误。它开始写标签而不是空格。我刚发现 - 用空格替换了标签并检查了我的设置。