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

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

isinstance('content', str)

返回True or False。

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

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

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

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

 

type返回值属于type类型

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

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄