import logging try: do-something-block except: logging.exception("Exception Logged") 转载于:https://www.cnblogs.com/dplearning/p/6606694.html