美文网首页
python技巧-运行时查看类名或者函数名

python技巧-运行时查看类名或者函数名

作者: reallocing | 来源:发表于2018-10-22 13:44 被阅读0次
# You can get the name of
# an object's class as a
# string:

>>> class MyClass: pass

>>> obj = MyClass()
>>> obj.__class__.__name__
'MyClass'

# Functions have a
# similar feature:

>>> def myfunc(): pass

>>> myfunc.__name__
'myfunc'

相关文章

网友评论

      本文标题:python技巧-运行时查看类名或者函数名

      本文链接:https://www.haomeiwen.com/subject/bbqgzftx.html