获取实例的类名?

不想你离开。 提交于 2020-04-07 01:34:38

问题:

How do I find out a name of class that created an instance of an object in Python if the function I am doing this from is the base class of which the class of the instance has been derived? 如果我从中执行此操作的函数是实例的类派生的基类,如何找出在Python中创建对象实例的类的名称?

Was thinking maybe the inspect module might have helped me out here, but it doesn't seem to give me what I want. 想到也许检查模块可能在这里帮助了我,但它似乎没有给我我想要的东西。 And short of parsing the __class__ member, I'm not sure how to get at this information. 如果没有解析__class__成员,我不知道如何获取这些信息。


解决方案:

参考一: https://stackoom.com/question/28vU/获取实例的类名
参考二: https://oldbug.net/q/28vU/Getting-the-class-name-of-an-instance
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!