为什么我会收到“IndentationError: expected an indented block"? [英] Why am I getting "IndentationError: expected an indented block"?
本文介绍了为什么我会收到“IndentationError: expected an indented block"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
if len(trashed_files) == 0 :
print "No files trashed from current dir ('%s')" % os.path.realpath(os.curdir)
else :
index=raw_input("What file to restore [0..%d]: " % (len(trashed_files)-1))
if index == "*" :
for tfile in trashed_files :
try:
tfile.restore()
except IOError, e:
import sys
print >> sys.stderr, str(e)
sys.exit(1)
elif index == "" :
print "Exiting"
else :
index = int(index)
try:
trashed_files[index].restore()
except IOError, e:
import sys
print >> sys.stderr, str(e)
sys.exit(1)
我得到:
elif index == "" :
^
IndentationError: expected an indented block
推荐答案
如错误消息所示,您有缩进错误.这可能是由制表符和空格混合引起的.
As the error message indicates, you have an indentation error. It is probably caused by a mix of tabs and spaces.
这篇关于为什么我会收到“IndentationError: expected an indented block"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文