溫馨提示×

python typeof函數(shù)的作用是什么

小億
210
2024-03-11 10:16:21
欄目: 編程語言

typeof不是Python內(nèi)置函數(shù),正確的是使用type函數(shù)來獲取對象的類型。type函數(shù)的作用是返回一個對象的類型。例如:

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

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

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

0