小编Nat*_*han的帖子

Python:继续迭代for循环异常

for在Python中有一个简单的循环,即使异常块包含一个异常块,也会退出异常continue.当它击中IndexError并退出for循环时,仍有大约10行可供阅读.我在这里错过了什么?

for row in hkx:  ##'hkx' are rows being read in from 'csv.open'
    try:
        print row[2],row[4]
    except IndexError, e:
        print 'Error:',e
        print 'Row Data:',len(row),row
        continue  ## I thought this would just move on to the next row in 'hkx' 
Run Code Online (Sandbox Code Playgroud)

(对不起,这里的Python新手......)提前致谢!

python for-loop exception

17
推荐指数
1
解决办法
4万
查看次数

标签 统计

exception ×1

for-loop ×1

python ×1