Python List len()方法

Python 教程 · 2019-02-02 20:12:22

描述

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

语法

len()方法语法:

len(list)

参数

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

返回值

返回列表元素个数。

实例

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

#!/usr/bin/python

list1, list2 = [123, 'xyz', 'zara'], [456, 'abc']

print "First list length : ", len(list1);
print "Second list length : ", len(list2);

以上实例输出结果如下:

First list length :  3
Second lsit length :  2

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

查看所有标签

HTML Dog

HTML Dog

Patrick Griffiths / New Riders Press / 2006-11-22 / USD 49.99

For readers who want to design Web pages that load quickly, are easy to update, accessible to all, work on all browsers and can be quickly adapted to different media, this comprehensive guide represen......一起来看看 《HTML Dog》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试