python如何计算列表内各元素的个数?
程序员文章站
2022-04-24 21:39:06
python如何计算列表内各元素的个数?
list = [1,2,3,4,5,6,7,5,4,3,2,12]
set = set(list)
dict = {}...
python如何计算列表内各元素的个数?
list = [1,2,3,4,5,6,7,5,4,3,2,12] set = set(list) dict = {} for item in set: dict.update({item:list.count(item)})