Python type() 函数
实例
返回这些对象的类型:
a = ('apple', 'banana', 'cherry') b = "Hello World" c = 55 x = type(a) y = type(b) z = type(c)
定义和用法
type() 函数返回指定对象的类型。
语法
type(object, bases, dict)
参数值
参数 | 描述 |
---|---|
object | 必需。如果仅设置一个参数,则 type() 函数将返回此对象的类型。 |
bases | มีทางเลือก กำหนดหลักฐาน |
dict | มีทางเลือก กำหนดชื่อชนิดที่มีการกำหนดโดย class |