Python3 List len()方法

Python 3 教程 · 2019-02-06 11:13:28

描述

len() 方法返回列表元素个数。

语法

len()方法语法:

len(list)

参数

  • list -- 要计算元素个数的列表。

返回值

返回列表元素个数。

实例

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

#!/usr/bin/python3

list1 = ['Google', 'Codercto', 'Taobao']
print (len(list1))
list2=list(range(5)) # 创建一个 0-4 的列表
print (len(list2))

以上实例输出结果如下:

3
5

点击查看所有 Python 3 教程 文章: https://codercto.com/courses/l/10.html

查看所有标签

Elements of Information Theory

Elements of Information Theory

Thomas M. Cover、Joy A. Thomas / Wiley-Blackwell / 2006-7 / GBP 76.50

The latest edition of this classic is updated with new problem sets and material The Second Edition of this fundamental textbook maintains the book's tradition of clear, thought-provoking instr......一起来看看 《Elements of Information Theory》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具