69pao国产精品视频-久久精品一区二区二三区-精品国产精品亚洲一本大道-99国产综合一区久久

Python List len()方法

Python List len()方法

Python 列表 ListPython 列表 List

len() 方法返回列表元素個數(shù)。

 

語法

len()方法語法:

len(list)

 

參數(shù)

  • list -- 要計算元素個數(shù)的列表。

 

返回值

返回列表元素個數(shù)。

 

實例

以下實例展示了 len()函數(shù)的使用方法:

#!/usr/bin/python

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

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

以上實例輸出結(jié)果如下:

First list length :  3
Second lsit length :  2

Python 列表 ListPython 列表 List

下一節(jié):Python List max()方法

Python 教程

相關(guān)文章