python如何获取变量类型
在Python中,可以使用type()
函数来获取一个变量的类型。示例如下:
x = 5
print(type(x)) # <class 'int'>
y = 3.14
print(type(y)) # <class 'float'>
z = "Hello"
print(type(z)) # <class 'str'>
type()
函数将返回变量的类型,例如int
表示整数类型,float
表示浮点数类型,str
表示字符串类型等。
阅读剩余
THE END