How to check if variable is a specific class in python?

前端 未结 3 1531
小鲜肉
小鲜肉 2020-12-31 00:43

I have a variable \"myvar\" that when I print out its type(myvar)

the output is:


If

3条回答
  •  轮回少年
    2020-12-31 01:31

    if any(map(lambda x: isinstance(x, my.object.kind), my_list_of_objects)):
        print "Found one!"
    

提交回复
热议问题