温馨提示×

python typeof函数的作用是什么

小亿
115
2024-03-11 10:16:21
栏目: 编程语言

typeof不是Python内置函数,正确的是使用type函数来获取对象的类型。type函数的作用是返回一个对象的类型。例如:

x = 5
print(type(x))  # <class 'int'>

y = "Hello"
print(type(y))  # <class 'str'>

z = [1, 2, 3]
print(type(z))  # <class 'list'>

0