我有一个包含多个文件的大型 Python 脚本,我需要知道调用方法的位置。 python 中是否有类似 php 中的 debug_backtrace 的回溯函数?
最佳答案
参见 traceback模块。
import traceback
def foo():
bar()
def bar():
baz()
def baz():
traceback.print_stack()
# or trace = traceback.extract_stack()
foo()
关于python - 如何回溯 python 2.7 中的函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10330119/