0
点赞
收藏
分享

微信扫一扫

python 获取当前运行的 class 和 方法的名字

五殳师兄 2022-08-23 阅读 108

# coding=utf-8

import sys
class Hello():

def hello(self):
print('the name of method is ## {} ##'.format(sys._getframe().f_code.co_name))
print('the name of class is ## {} ##'.format(self.__class__.__name__))

if __name__ == "__main__":
h = Hello()
h.hello()

  



举报

相关推荐

0 条评论