摘要:
内置方法: __名字__ 他的表述有多种: 类中的特殊方法\内置方法 双下方法 魔术方法 magic_method类中的每一个双下方法都有它自己的特殊意义__call__ 相当于 对象() __len__ len(obj)__new__ 特别重要 开辟内存空间的 类的构造方法 __call__ cl 阅读全文
posted @ 2020-03-16 18:00
蜗牛般庄
阅读(119)
评论(0)
推荐(0)
摘要:
反射 :用字符串数据类型的变量名来访问这个变量的值 反射的方法: getattr hasattr setattr delattr 先来看看代码: class Student: def __init__(self,name): self.name = name def check_course(sel 阅读全文
posted @ 2020-03-16 16:03
蜗牛般庄
阅读(117)
评论(0)
推荐(0)
摘要:
isinstance() 判断对象所属类型,包括继承关系 class A:pass class B(A):pass b = B() print(isinstance(b,B)) #o,t True print(isinstance(b,A)) #o,t True list()函数其实也是一种对象 l 阅读全文
posted @ 2020-03-16 15:14
蜗牛般庄
阅读(125)
评论(0)
推荐(0)