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字典