两种方式:
#!/usr/bin/env python3
#coding:utf-8
import sys, inspect
def test_a():
print('func name: ', sys._getframe().f_code.co_name)
def test_b():
print('func name: ', inspect.stack()[0][3])
test_a()
test_b()
https://wenku.baidu.com/view/ae74f4e60f22590102020740be1e650e52eacfc8.html
标签:函数,python,print,sys,获取,func,test,name From: https://www.cnblogs.com/i-shu/p/16826794.html