Manual
Return true if the object argument is an instance of the classinfo argument, or of a (direct, indirect or virtual) subclass thereof. If object is not an object of the given type, the function always returns false. If classinfo is a tuple of type objects (or recursively, other such tuples), return true if object is an instance of any of the types. If classinfo is not a type or tuple of types and such tuples, a TypeError exception is raised.
直译
如果object参数是classinfo参数的一个实例或子类(直接、间接或虚拟)实例,返回True。如果object不是给定的类型的对象,函数返回False。如果classinfo是一个类型对象的元组(或递归等其他元组),且object是一个任意类型的实例,则返回True。如果classinfo不是类型或类型的元组,则会引发TypeError异常。
实例
>>> class 优快云:
def __init__(self):
print('Hello 优快云er!')
>>> isinstance(优快云(), 优快云)
Hello 优快云er!
True
>>> class 优快云er(优快云):
def __init__(self):
print('Hello world!')
>>> isinstance(优快云er(), 优快云)
Hello world!
True
>>> x = 1
>>> isinstance(x, 优快云)
False