曾经,博主的房东养了只金毛叫奶茶,今天就拿它当议题好了. 博主写本文时正在被广州的蚊子围攻. #反射练习 class animal(object): def __init__(self,name,fool): self.name = name self.fool = fool def dog(self): print("This is %s,it's a dog.it eat %s"%(self.name,self.fool)) d = animal("奶茶",&q…
一.isinstance和issubclass isinstance(obj,cls)检查是否obj是否是类 cls 的对象 issubclass(sub, super)检查sub类是否是 super 类的派生类 class Foo: pass class Bar(Foo): pass f = Foo() b = Bar() print(isinstance(f,Foo)) print(issubclass(Bar,Foo)) print(isinstance(Bar,Foo)) print(i…