统计单词次数 作为字典存储
cotent = "who have an apple apple is free free is money you know" result = {} for s in content.split(""): if s in result: result[s] + =1 else: result[s] = 1 print result
反转上面的结果
res = {}
for k,v in result.items():
res.setdefault(v,[])
res[v].append(k)