如果我有
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}
如果我有
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}
你可以使用计数器:
from collections import Counter
a = Counter(map(tuple, a))