详解Python中的type()方法的使用,pythontype
详解Python中的type()方法的使用,pythontype
type()方法返回传递变量的类型。如果传递变量是字典那么它将返回一个字典类型。
语法
以下是type()方法的语法:
type(dict)
参数
- dict -- 这是字典
返回值
此方法返回传递变量的类型。
例子
下面的例子显示type()方法的使用
#!/usr/bin/python dict = {'Name': 'Zara', 'Age': 7}; print "Variable Type : %s" % type (dict)
当我们运行上面的程序,它会产生以下结果:
Variable Type : <type 'dict'>
相关内容
- 在Python中操作字典之clear()方法的使用,pythonclear
- 浅谈Python中copy()方法的使用,pythoncopy
- 在Python中操作字典之fromkeys()方法的使用,pythonfromkeys
- 在Python中用get()方法获取字典键值的教程,pythonget
- 在Python中用has_key()方法查找键是否存在的教程,python
- Python中使用items()方法返回字典元素对的教程,pythonit
- 在Python中用keys()方法返回字典键的教程,pythonkeys
- 在Python中操作字典之setdefault()方法的使用,pythonsetdef
- python计算时间差的方法,python计算时间差
- 在Python中使用swapCase()方法转换大小写的教程,pythonsw
评论关闭