>>> l = ["egg", "bacon", "spam", "spam", "eggs", "spam", "bacon","egg"] >>> nl = list(set(l)) >>> result = [] >>> for i in nl: ... c = 0 ... for j in l: ... if i == j: ... c += 1 ... result.append([i,c]) ... >>> result [['bacon', 2], ['eggs', 1], ['egg', 2], ['spam', 3]]本回答被提问者采纳