当前位置:主页 > 软件编程 > Python代码 >

详解Python中的type()方法的使用

时间:2021-02-08 09:35:23 | 栏目:Python代码 | 点击:

 type()方法返回传递变量的类型。如果传递变量是字典那么它将返回一个字典类型。
语法

以下是type()方法的语法:

type(dict)

参数

返回值

此方法返回传递变量的类型。
例子

下面的例子显示type()方法的使用

#!/usr/bin/python

dict = {'Name': 'Zara', 'Age': 7};
print "Variable Type : %s" % type (dict)

当我们运行上面的程序,它会产生以下结果:

Variable Type : <type 'dict'>

您可能感兴趣的文章:

相关文章