Python 字典(Dictionary) len()方法

栏目: 编程语言 · Python · 编程教程 · python 教程 · 发布时间: 6年前

内容简介:Python 字典(Dictionary) len() 函数计算字典元素个数,即键的总数。

描述

Python 字典(Dictionary) len() 函数计算字典元素个数,即键的总数。

语法

len()方法语法:

len(dict)

参数

  • dict -- 要计算元素个数的字典。

返回值

返回字典的元素个数。

实例

以下实例展示了 len()函数的使用方法:

#!/usr/bin/python

dict = {'Name': 'Zara', 'Age': 7};
print "Length : %d" % len (dict)

以上实例输出结果为:

Length : 2

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Thinking Recursively

Thinking Recursively

Eric S. Roberts / Wiley / 1986-1-17 / USD 85.67

The process of solving large problems by breaking them down into smaller, more simple problems that have identical forms. Thinking Recursively: A small text to solve large problems. Concentrating on t......一起来看看 《Thinking Recursively》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具