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类型

 

posted @ 2019-04-08 13:02  lypbendlf  阅读(227)  评论(0编辑  收藏  举报