vote=['鲁智深','柴进','宋江','吴用','林冲','卢俊义', '柴进','柴进','孙二娘','史进','吴用','卢俊义','柴进', '林冲','宋江','宋江','卢俊义','吴用','吴用'] voteCount=dict() for name in vote: if name not in voteCount: #字典中还没名字 voteCount[name]=1 else: voteCount[name]+=1 #print("得票情况:",voteCount) result=list(voteCount.items()) result.sort(key=lambda x:x[1],reverse=True) for x in result: print("{:s}\t{:d}".format(x[0],x[1]))