Python3 dictionary.type()方法

type()方法返回傳遞變數的類型。如果傳遞變數是字典,那麼它會返回一個字典類型。

語法

以下是 type() 方法的語法-
type(dict)

參數

  • dict -- 這是一個字典

返回值

此方法返回傳遞變數的類型。

示例

下麵的示例演示 type() 方法的使用。
#!/usr/bin/python3

dict = {'Name': 'Manni', 'Age': 7, 'Class': 'First'}
print ("Variable Type : %s" %  type (dict))
當我們運行上面的程式,會產生以下結果 -
Variable Type : <type 'dict'>

上一篇: Python3元組 下一篇: Python3字典