# 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'
# 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
网友评论