How to properly ignore exceptions

前端 未结 11 2120
粉色の甜心
粉色の甜心 2020-11-22 02:18

When you just want to do a try-except without handling the exception, how do you do it in Python?

Is the following the right way to do it?

try:
    s         


        
11条回答
  •  终归单人心
    2020-11-22 02:45

    I needed to ignore errors in multiple commands and fuckit did the trick

    import fuckit
    
    @fuckit
    def helper():
        print('before')
        1/0
        print('after1')
        1/0
        print('after2')
    
    helper()
    

提交回复
热议问题