python中len字典_Python 字典(Dictionary) len()方法

编程入门 行业动态 更新时间:2024-10-25 14:29:14

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()方法

本文发布于:2023-06-14 09:48:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1462594.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字典   方法   len   python   _Python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!