test = [1,2,3,5,2,4,2,4,6,7,3,5,6,2]
test_stat = {}
for i in set(test):
test_stat[i] = test.count(i)
print(test_stat)
result.png
test = [1,2,3,5,2,4,2,4,6,7,3,5,6,2]
test_stat = {}
for i in set(test):
test_stat[i] = test.count(i)
print(test_stat)
result.png
本文标题:Python计算列表中的每个元素出现的次数
本文链接:https://www.haomeiwen.com/subject/mqdlnqtx.html
网友评论