【发布时间】:2017-09-22 07:39:14
【问题描述】:
当我运行 try except 语句来捕获 IndentationError 时,该语句不起作用,这是我的代码:
try:
for i in range(2):
print(i)
except IndentationError:
print('IndentationError')
然后我得到了结果:
try:
for i in range(2):
print(i)
except IndentationError:
print('IndentationError')
File "<ipython-input-57-5df0f4cccb57>", line 3
print(i)
^
IndentationError: expected an indented block```
为什么 try except 语句在这种情况下不起作用?
【问题讨论】:
标签: python-3.x