标签:
>>> isinstance(2,int) True >>> isinstance(2,(int,float)) True >>> isinstance(2,[int,float]) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: isinstance() arg 2 must be a class, type, or tuple of classes and types
>>> class a: ... pass >>> class b(a): ... pass >>> class c(a): ... pass ... >>> issubclass(a,a) True >>> issubclass(a,b) False >>> issubclass(b,a) True >>> issubclass(b,[a,c]) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: issubclass() arg 2 must be a class or tuple of classes >>> issubclass(b,(a,c)) True >>> issubclass(b,(c,a)) True
标签:
原文地址:http://www.cnblogs.com/caizhenzhen/p/5081014.html