Python3 dictionary.type()方法

2019-10-16 23:10:06
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'>