一,type()函数得到数据/函数类型
1,type()函数
功能:type() 函数如果只有第一个参数则返回对象的类型,
三个参数返回新的类型对象
语法:
type(object)
type(name, bases, dict)
参数: name : 类的名称
bases : 基类的元组
dict : 字典,类内定义的命名空间变量
返回值: 一个参数时返回对象类型,
三个参数时返回新的类型对象
2,应用:
print(type('abc')) # str
print(type(123)) # int
print(type(True)) # bool
print(type(None)) # NoneType
print(type([2])) # list
print(type({0: 'zero'})) # dict
# 查看type()返回结果的类型是type,也就是对