菜鸟教程 -- 学的不仅是技术,更是梦想!

Python 基础教程
(追記) (追記ここまで)

Python List len()方法

Python 列表 Python 列表


描述

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 列表 Python 列表

AI 思考中...

点我分享笔记

  • 昵称 (必填)
  • 邮箱 (必填)
  • 引用地址

AltStyle によって変換されたページ (->オリジナル) /