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://www.codercto.com/courses/l/8.html

查看所有标签

Professional JavaScript for Web Developers

Professional JavaScript for Web Developers

Nicholas C. Zakas / Wrox / 2009-1-14 / USD 49.99

This eagerly anticipated update to the breakout book on JavaScript offers you an in-depth look at the numerous advances to the techniques and technology of the JavaScript language. You'll see why Java......一起来看看 《Professional JavaScript for Web Developers》 这本书的介绍吧!

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换

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

正则表达式在线测试

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具