from collections import Counter
c = Counter(ls)
print (dict(c))
dictInfo = {}
for name in data:
if name not in dictInfo:
dictInfo[name] = 1
else:
dictInfo[name] += 1
for name,value in dictInfo.items():
print(name + ": " + value,end=" ")
如果觉得答案对你有帮助,请点击下采纳,谢谢~