【发布时间】:2020-05-12 06:53:44
【问题描述】:
有没有办法从函数中找到函数名?
def some_function():
function_name = ... # some way of retrieving the name 'some_function'
print(function_name)
function_name 的预期值为字符串:'some_function'
【问题讨论】:
-
inspect.currentframe().f_code.co_name似乎执行最快