小编PKa*_*ura的帖子

获取导致IndexError异常的索引

是否有可能获得导致IndexError异常的索引?

示例代码:

arr = [0, 2, 3, 4, 5, 6, 6]
try:  
   print arr[10] # This will cause IndexError
except IndexError as e:
    print e.args # Can I get which index (in this case 10) caused the exception?
Run Code Online (Sandbox Code Playgroud)

python python-2.7

10
推荐指数
2
解决办法
1624
查看次数

标签 统计

python ×1

python-2.7 ×1