找到列表中出现最频繁的数
1
2
3
>>> test = [1,2,3,4,2,2,3,1,4,4,4]
>>> print(max(set(test),key=test.count))
4
注:
max 函数用法
1
max(iterable, key, default)
list.count(ele) 函数用法
1
list.count(element)
找到列表中出现最频繁的数
1
2
3
>>> test = [1,2,3,4,2,2,3,1,4,4,4]
>>> print(max(set(test),key=test.count))
4
注:
max 函数用法
1
max(iterable, key, default)
list.count(ele) 函数用法
1
list.count(element)
发现新版本的内容。