1. class A:
    2. def __init__(self):
    3. print('this is __init__ function')
    4. def __str__(self):
    5. print('this is __str__ function')
    6. """类、函数、方法、描述器或生成器实例的名称"""
    7. print(A.__name__) # A
    8. """类实例所属的类"""
    9. print(A().__class__) # <class '__main__.A'>
    10. """由类对象的基类所组成的元组"""
    11. print(A.__bases__) # (<class 'object'>,)
    12. """一个字典或其他类型的映射对象,用于存储对象的(可写)属性"""
    13. print(A.__dict__)
    14. # {'__module__': '__main__', '__init__': <function A.__init__ at 0x7f95b020db00>,
    15. # '__str__': <function A.__str__ at 0x7f95a0035170>, '__dict__': <attribute '__dict__' of 'A' objects>,
    16. # '__weakref__': <attribute '__weakref__' of 'A' objects>, '__doc__': None}