Python 未缩进与任何外部缩进级别不匹配

Python 未缩进与任何外部缩进级别不匹配,python,indentation,Python,Indentation,可能重复: 我编写了以下python代码,但我看不出问题的原因,但得到以下错误消息: def post(自我): ^ 缩进错误:未缩进与任何外部缩进级别不匹配 class MainHandler(webapp2.RequestHandler): def get(self): self.response.out.write(form) def post(self): self.response.out.write("valid") app = webapp2.WSGIAppl

可能重复:

我编写了以下python代码,但我看不出问题的原因,但得到以下错误消息:

def post(自我): ^ 缩进错误:未缩进与任何外部缩进级别不匹配

class MainHandler(webapp2.RequestHandler):
def get(self):
    self.response.out.write(form)

def post(self):
    self.response.out.write("valid")

app = webapp2.WSGIApplication([('/', MainHandler)],debug=True)

如果您混淆了空格和选项卡,将不胜感激。在
python-tt
中运行脚本以验证。

您的代码示例中充满了选项卡字符。如果将制表符与空格混合,则错误几乎是已知的

使用清理源代码,将编辑器切换为仅使用空格,然后修复缩进:

python -m tabnanny -v path/to/your/code.py

非常感谢我设法解决了我和tab的问题spaces@FrancisTchatchoua当前位置如果答案对您有帮助,您介意将其标记为已接受吗?看见