Python type()内置函数 --判断数据类型

type() 函数是用来查询数据类型,只有知道属于什么对象,才能使用该对象的方法和属性

一些例子

1
2
3
4
5
print(type('雨园博客'))
print(type(1314))
print(type(88.88))
print(type(['雨园博客', 1314, 88.88]))
print(type({'雨园': '博客', 13: 14}))

输出

1
2
3
4
5
<class 'str'>
<class 'int'>
<class 'float'>
<class 'list'>
<class 'dict'>

类型说明

str : 字符串
int : 整数
float : 浮点数
list : 列表
dict : 字典