word_dict = {} #exclude_str = ",。!?、()【】<>《》=:+-*—“”…" for char in temp_pro: #for char in temp_pro[i]: #if char not in exclude_str: if char not in word_dict: # 为了去掉空白 word_dict[char] = 1 else: word_dict[char] += 1 lstWords = sorted(word_dict.items(), key=lambda x: x[1], reverse=True)
#reverse=True这个是允许覆盖的意思