阅读量:118
在Python中,可以使用type()函数来查看变量的类型。示例如下:
x = 5
print(type(x)) # 输出:
y = 3.14
print(type(y)) # 输出:
z = "hello"
print(type(z)) # 输出:
is_valid = True
print(type(is_valid)) # 输出:
在上面的示例中,通过type()函数将变量传递给它,它将返回变量的类型。