import inspect
def a():
print("打印调用了函数a的函数名:",inspect.stack()[1][3])
def b():
a()
def c():
a()
b()
c()
打印调用了函数a的函数名: b
打印调用了函数a的函数名: c
inspect模块用法
最新推荐文章于 2024-02-07 00:00:00 发布
import inspect
def a():
print("打印调用了函数a的函数名:",inspect.stack()[1][3])
def b():
a()
def c():
a()
b()
c()
打印调用了函数a的函数名: b
打印调用了函数a的函数名: c