Python字典type()函數

Python字典type()函數返回傳遞變數的類型。 如果傳遞變數是字典,那麼它將返回字典類型。

語法

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

type(dict)

參數

  • dict - 這是對象(字典,列表等),需要求出類型的對象。

返回值

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

示例

以下示例顯示type()方法的用法 -

#!/usr/bin/python3

dict = {'Name': 'Maxsu', 'Age': 7, 'Class': 'First'}
print ("Variable Type : %s" %  type (dict))

當運行上面的程式,它產生以下結果 -

Variable Type : <type 'dict'>

上一篇: Python字典 下一篇: Python日期和時間