On Error Resume Next in Python

后端 未结 7 1177
栀梦
栀梦 2020-12-11 02:07

Snippet 1

do_magic() # Throws exception, doesn\'t execute do_foo and do_bar
do_foo()
do_bar()

Snippet 2

try:
    do_mag         


        
7条回答
  •  难免孤独
    2020-12-11 02:31

    If there are no parameters...

    funcs = do_magic, do_foo, do_bar
    
    for func in funcs:
        try:
            func()
        except:
            continue
    

提交回复
热议问题