How to print an exception in Python 3?

前端 未结 7 2104
有刺的猬
有刺的猬 2021-01-31 13:48

Right now, I catch the exception in the except Exception: clause, and do print(exception). The result provides no information since it always prints

相关标签:
7条回答
  • 2021-01-31 14:46

    I've use this :

    except (socket.timeout, KeyboardInterrupt) as e:
        logging.debug("Exception : {}".format(str(e.__str__).split(" ")[3]))
        break
    

    Let me know if it does not work for you !!

    0 讨论(0)
提交回复
热议问题