Python 字典(Dictionary) len()方法
描述
Python 字典(Dictionary) len() 函数计算字典元素个数,即键的总数。高佣联盟 www.cgewang
语法
len()方法语法:
len(dict)
参数
dict -- 要计算元素个数的字典。
返回值
返回字典的元素个数。
实例
以下实例展示了 len()函数的使用方法:
#!/usr/bin/python
dict = {'Name': 'Zara', 'Age': 7};
print "Length : %d" % len (dict)
以上实例输出结果为:
Length : 2
Python 字典(Dictionary) clear()方法
Python 字典(Dictionary) clear()方法 描述 Python 字典(Dictionary) clear() 函数用于删除字典内所有元素.高佣联盟 www.cgewang ...
Python 字典(Dictionary) type()方法
Python 字典(Dictionary) type()方法 描述 Python 字典(Dictionary) type() 函数返回输入的变量类型,如果变量是字典就返回字典类型.高佣联盟 www.c ...
Python 字典(Dictionary) str()方法
更多推荐
python中len字典_Python 字典(Dictionary) len()方法
发布评论