在Python中,type()函数用于返回对象的类型。语法如下:
type(object)其中,object是要获取类型的对象。示例如下:
num = 10print(type(num))# <class 'int'>string = "Hello"print(type(string))# <class 'str'>lst = [1, 2, 3]print(type(lst))# <class 'list'>dict = {"name": "Alice", "age": 30}print(type(dict))# <class 'dict'>type()函数可以用来检查实例的类型,或者将其用于控制流程。
上一篇:python怎么判断对象是否为空
下一篇:C++句柄类的作用和特点是什么
python









