python3_统计计数
(13条消息) python中统计计数的几种方法_Python热爱者的博客-CSDN博客_python 连续数字统计
1、count()
list1 = [123,"one","two","three","one","three","two","four",123] count_123 = list1.count(123) print("123 元素个数:" , count_123) #123 元素个数: 2 count_one = list1.count('one') print("one 元素个数:" , count_one) #one 元素个数: 2 count_two = list1.count('two') print("two 元素个数:" , count_two) #two 元素个数: 2 count_three = list1.count('three') print("three 元素个数:" , count_three) #three 元素个数: 2 count_four = list1.count('four') print("four 元素个数:" , count_four) #four 元素个数: 1

浙公网安备 33010602011771号