成免费的crm,久久国产精品新农夫导航新妓网,恋夜秀场全部视频安卓手机,女校花强奷在线播放A级

Python List count()方法

Python List count()方法

Python 列表 ListPython 列表 List

count() 方法用于統計某個元素在列表中出現的次數。

 

語法

count()方法語法:

list.count(obj)

 

參數

  • obj -- 列表中統計的對象。

 

返回值

返回元素在列表中出現的次數。

 

實例

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

#!/usr/bin/python

aList = [123, 'xyz', 'zara', 'abc', 123];

print "Count for 123 : ", aList.count(123);
print "Count for zara : ", aList.count('zara');

以上實例輸出結果如下:

Count for 123 :  2
Count for zara :  1

Python 列表 ListPython 列表 List

下一節:Python List extend()方法

Python 教程

相關文章