标签:htm bin 描述 ted span 参数 class 函数 ret
count() 方法用于统计某个元素在列表中出现的次数。
count()方法语法:
list.count(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
转自:http://www.runoob.com/python/att-list-count.html
标签:htm bin 描述 ted span 参数 class 函数 ret
原文地址:http://www.cnblogs.com/HITSZ/p/7102389.html