没懂
没懂
dic_word='When I wrote the following pages, or rather the bulk of them,\ I lived alone, in the woods, woods woods a mile from any neighbor, in a house which' dic_word=dic_word.lower() words= dic_word.split() word_freg={} #构建一个空字典,用于后续记录个单词的频次 for word in words: if word in word_freg.keys(): word_freg[word]+=1 else: word_freg[word]=1