您的位置:宽带测速网 > 编程知识 > python中怎么查看数据类型

python中怎么查看数据类型

2025-06-17 15:03来源:互联网 [ ]

在Python中,可以使用type()函数来查看数据的类型。

例如:

x = 5print(type(x))# 输出:<class 'int'>y = "Hello"print(type(y))# 输出:<class 'str'>z = [1, 2, 3]print(type(z))# 输出:<class 'list'>

通过调用type()函数并传入要查看类型的变量,即可获取该变量的数据类型。