【发布时间】:2018-03-26 06:04:12
【问题描述】:
我的 python 代码有问题。我认为我使用了正确的 python 结构,但它一直向我显示(意外的缩进错误)
class TopGamesPostPage(Handler):
def get(self):
self.render("topgamespost.html")
def post(self):
title = self.request.get('title')
info = self.request.get('info')
if title and info: --> unexpected indent error
p = Post(parent = blog_key(), title = title, info=info)
p.put()
self.redirect('/topgames/%s' % str(p.key().id()))
else:
error = "subject and content, please!"
self.render("topgamespost.html", title=title, info=info, error=error)
【问题讨论】:
-
试试像 Sublime 这样的编辑器。在 Sublime 中,如果你突出显示所有代码,你会看到空格的圆点和制表符的长破折号。如果他们混在一起,那就不行了。 Sublime 还具有转换为所有制表符或所有空格的工具。复制/粘贴代码时经常发生这种情况。
-
我使用的是 VS 2017,我的文件中没有混合空间
标签: python