代码如下:

    import logging
    
    try:
        # do something here
    except Exception as e:
        logging.exception(e)


参考:

https://stackoverflow.com/questions/30442236/how-to-prevent-too-broad-exception-in-this-case