python python转储变量异常

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python python转储变量异常相关的知识,希望对你有一定的参考价值。

# collect the variable from the caller functions
def f():
    a = 1
    b = 2
    1/0  # trigger the exception

try:
    f()
except:
    exc_type, exc_value, tb = sys.exc_info()
    if tb is not None:
        prev = tb
        curr = tb.tb_next
        while curr is not None:
            prev = curr
            curr = curr.f_back
        print(prev.tb_frame.f_globals)
# collect the variable from the caller functions
def f():
    a = 1
    b = 2
    1/0  # trigger the exception

try:
    f()
except:
    exc_type, exc_value, tb = sys.exc_info()
    if tb is not None:
        prev = tb
        curr = tb.tb_next
        while curr is not None:
            prev = curr
            curr = curr.tb_next
        print(prev.tb_frame.f_locals)

以上是关于python python转储变量异常的主要内容,如果未能解决你的问题,请参考以下文章