import inspect
def a():
print("打印调用了函数a的函数名:",inspect.stack()[1][3])
def b():
a()
def c():
a()
b()
c()
打印调用了函数a的函数名: b
打印调用了函数a的函数名: c
import inspect
def a():
print("打印调用了函数a的函数名:",inspect.stack()[1][3])
def b():
a()
def c():
a()
b()
c()
打印调用了函数a的函数名: b
打印调用了函数a的函数名: c