獲取實例的類名? - Getting the class name of an instance?

問題:

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中建立對象實例的類的名稱? html

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__成員,我不知道如何獲取這些信息。 python


解決方案:

參考一: https://stackoom.com/question/28vU/獲取實例的類名
參考二: https://oldbug.net/q/28vU/Getting-the-class-name-of-an-instance
相關文章
相關標籤/搜索