How to get back to the for loop after exception handling

后端 未结 3 1862
南笙
南笙 2021-01-30 22:39

I am ready to run this code but before I want to fix the exception handling:

for l in bios:
    OpenThisLink = url + l
    try:
        response = urllib2.urlope         


        
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-30 23:15

    Try is actually way more powerful than that. You can use the else block here too:

    try:
        stuff
    except Exception:
        print "oh no a exception"
    else:
        print "oh yay no exception"
    finally:
        print "leaving the try block"
    

提交回复
热议问题