Make python code continue after exception

后端 未结 3 1391
情深已故
情深已故 2021-02-01 02:53

I\'m trying to read all files from a folder that matches a certain criteria. My program crashes once I have an exception raised. I am trying to continue even if there\'s an exc

3条回答
  •  猫巷女王i
    2021-02-01 03:00

    You're code is doing exactly what you're telling it to do. When you get an exception, it jumps down to this section:

    except:
        print "error "+str(IOError)
        pass
    

    Since there's nothing after that, the program ends.

    Also, that pass is superfluous.

提交回复
热议问题