python isinstance()

isinstance

isinstance(object, classinfo)

Examples of this class is determined whether the object is a variable or

classinfo is type (tuple, dict, int, float)

To determine whether this is the type of variable

For example:

class objA: 
 Pass  
 
A = objA () 
B = ' A ' , ' V '  
C = ' A String '  
 
Print the isinstance (A, objA)   # Note that the use 
Print the isinstance (B, tuple) 
 Print the isinstance (C, of basestring) 
output The results: 
True 
True 
True

The classinfo isinstance may be a plurality of types of data: example:

= L [l, 2,3 ] 
the isinstance (L, (int, STR, List))
 *** Results ****** 
to true

 

 

Guess you like

Origin www.cnblogs.com/dushangguzhousuoli/p/10994778.html