一.isinstance(obj,cls)和issubclass(sub,super)
isinstance(obj,cls)检查obj是否是类cls的对象
class Foo(object): pass obj = Foo() print(isinstance(obj,Foo)) # True
时间: 2024-10-07 09:42:10
一.isinstance(obj,cls)和issubclass(sub,super)
isinstance(obj,cls)检查obj是否是类cls的对象
class Foo(object): pass obj = Foo() print(isinstance(obj,Foo)) # True