如何用Python获取当前执行的方法和类名?
- 内容介绍
- 相关推荐
本文共计87个文字,预计阅读时间需要1分钟。
当然可以,请您提供需要改写的原文,我会帮您进行修改。
# coding=utf-8import 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()
本文共计87个文字,预计阅读时间需要1分钟。
当然可以,请您提供需要改写的原文,我会帮您进行修改。
# coding=utf-8import 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()

