array(2) { ["docs"]=> array(0) { } ["count"]=> int(0) } 111string(0) "" int(1) int(10) int(70) int(8640000) string(13) "likecs_art_db" array(1) { ["query"]=> array(1) { ["match_all"]=> object(stdClass)#28 (0) { } } } array(1) { ["createtime.keyword"]=> array(1) { ["order"]=> string(4) "desc" } } int(10) int(0) int(8640000) array(2) { ["docs"]=> array(0) { } ["count"]=> int(0) } python 打印堆栈信息方法 - 爱码网

第一种方法使用logging模块

import logging


def test(self):
    try:
        1 / 0  # 触发异常  
    except BaseException as e:
        logging.exception(e)  # 方式2  
    finally:
        pass

第二种方法使用traceback模块

import traceback


def test(self):
    try:
        1 / 0  # 触发异常  
    except BaseException as e:
        msg = traceback.format_exc()
        print (msg)
    finally:
        pass

相关文章: