count() 统计某个元素在list中出现的次数
list.count(obj)
testlist = [123, 'abc', 'cdf', 'abc', 123, 123]
print("Count for 123 : ", testlist.count(123))
print("Count for abc : ", testlist.count('abc'))
结果
Count for 123 : 3
Count for abc : 2
list.count(obj)
testlist = [123, 'abc', 'cdf', 'abc', 123, 123]
print("Count for 123 : ", testlist.count(123))
print("Count for abc : ", testlist.count('abc'))
结果
Count for 123 : 3
Count for abc : 2