在Python中,type()是一個內置函數,用于獲取對象的類型。
type()的語法為: type(object)
其中,object是要檢查其類型的對象。
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’>