python中一切皆为对象,且python3中类与类型是一个概念,类型就是类

    1. # 类型dict就是类dict
    2. >>> list
    3. <class 'list'>
    4. # 实例化的到3个对象l1,l2,l3
    5. >>> l1=list()
    6. >>> l2=list()
    7. >>> l3=list()
    8. # 三个对象都有绑定方法append,是相同的功能,但内存地址不同
    9. >>> l1.append
    10. <built-in method append of list object at 0x10b482b48>
    11. >>> l2.append
    12. <built-in method append of list object at 0x10b482b88>
    13. >>> l3.append
    14. <built-in method append of list object at 0x10b482bc8>
    15. # 操作绑定方法l1.append(3),就是在往l1添加3,绝对不会将3添加到l2或l3
    16. >>> l1.append(3)
    17. >>> l1
    18. [3]
    19. >>> l2
    20. []
    21. >>> l3
    22. []
    23. # 调用类list.append(l3,111)等同于l3.append(111)
    24. >>> list.append(l3,111) #l3.append(111)
    25. >>> l3
    26. [111]
    1. class MufengStudent:
    2. school = 'mufeng'
    3. def learn(self):
    4. print('is learning')
    5. def eat(self):
    6. print('is sleeping')
    7. print(MufengStudent) # <class '__main__.MufengStudent'>