python 获取当前函数的 函数名 sys._getframe().f_code.co_name

来源:互联网 发布:php参考手册 编辑:程序博客网 时间:2024/05/17 09:01
# -*- coding:utf-8 -*-import sysclass test_class():    def hello(self):        print(sys._getframe().f_code.co_name)def hello_world():    print('hello_world!')    print(sys._getframe().f_code.co_name)if __name__ == '__main__':    ttt = test_class()    ttt.hello()    hello_world()
hellohello_world!hello_worldProcess finished with exit code 0
原创粉丝点击