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日期和时间