0

如果我有

a = [['a','b','c'],['b','c','d'],['a','b','c'],['e','f','g'],['b','c','d']]

如何得到

a = {('a','b','c'):2,('b','c','d'):2,('e','f','g'):1}
4

1 回答 1

0

你可以使用计数器

from collections import Counter

a = Counter(map(tuple, a))
于 2012-12-02T20:12:41.727 回答