【python】type()、instance()
1 >>> a=520 2 >>> type(a) 3 <class 'int'> 4 >>> a='520' 5 >>> type(a) 6 <class 'str'> 7 >>> a=5.2 8 >>> type(a) 9 <class 'float'> 10 >>> a=True 11 >>> type(a) 12 <class 'bool'>
1 >>> a=True 2 >>> type(a) 3 <class 'bool'> 4 >>> isinstance(a,bool) 5 True 6 >>> isinstance(a,int) 7 True 8 >>> isinstance(a,str) 9 False 10 >>> isinstance(a,float) 11 False 12 >>>