use*_*564 1 python list
我如何计算3列表中出现的次数,例如[[1,2,3,4],[2,3,4,5],[5,6,7,5]] 输出应该是类似的[1,1,0]
[[1,2,3,4],[2,3,4,5],[5,6,7,5]]
[1,1,0]
Nic*_*las 6
您可以使用以下方法list.count(element):
list.count(element)
my_lists = [[1,2,3,4], [2,3,4,5], [5,6,7,5]] [l.count(3) for l in my_lists] >> [1, 1, 0]
归档时间:
13 年,3 月 前
查看次数:
84 次
最近记录: