Py中查看数据类型【转载】

转自:https://www.jianshu.com/p/bb5cc438e3b2

1.内置函数isinstance(object, (type1,type2...))

isinstance('content', str)

返回True or False。

 2.使用内置函数type(object)

>>>type(1)    
<type 'int'>    #返回整形
>>>type('content')
<type 'str'>    #返回字符串

type返回值属于type类型

>>>type(type(1))
<type 'type'>    #返回type类型

猜你喜欢

转载自www.cnblogs.com/BlueBlueSea/p/10669854.html