Skip to content

Latest commit

 

History

History
25 lines (19 loc) · 554 Bytes

41.md

File metadata and controls

25 lines (19 loc) · 554 Bytes
@author jackzhenguo
@desc 
@date 2019/3/13

41 isinstance

判断object是否为类classinfo的实例,是返回true

In [1]: class Student():
   ...:     def __init__(self,id,name):
   ...:         self.id = id
   ...:         self.name = name
   ...:     def __repr__(self):
   ...:         return 'id = '+self.id +', name = '+self.name

In [2]: xiaoming = Student(id='001',name='xiaoming')

In [3]: isinstance(xiaoming,Student)
Out[3]: True
[上一个例子](40.md) [下一个例子](42.md)