日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

作业7

發布時間:2025/3/20 编程问答 17 豆豆
生活随笔 收集整理的這篇文章主要介紹了 作业7 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

文件方式實現完整的英文詞頻統計實例

1.讀入待分析的字符串

2.分解提取單詞?

3.計數字典

4.排除語法型詞匯

5.排序

6.輸出TOP(20)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 >>> fo=open('123.txt','w') >>> fo.write('''I messed up tonight, I lost another fight I still mess up but I'll just start again I keep falling down, I keep on hitting the ground I always get up now to see what's next Birds don't just fly, they fall down and get up Nobody learns without getting it won I won't give up, no I won't give in Til I reach the end, then I'll start again No I won't leave, I wanna try everything I wanna try even though I could fail I won't give up, no I won't give in Til I reach the end and then I'll start again No I won't leave, I wanna try everything I wanna try even though I could fail''') 574 >>> fo.close()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 fo=open('123.txt','r') song=fo.read() ?? song=song.lower()?#小寫 for?i?in?',.': ????song=song.replace(i,' ')??#替換標點符號 words=song.split()??#分單詞 #print(words) ?? dic={}?#字典 keys=set(words)?#集合 #print(keys) ?? for?i?in?keys: ????dic[i]=words.count(i)?#出現單詞的次數 ? #print(dic) ?? wc?=?list(dic.items())?#列表 ?? wc.sort(key=lambdax:x[1],reverse=True) #print(wc) ?? for?i?in?range(20): ????print(wc[i]) fo.close()

轉載于:https://www.cnblogs.com/z1-z/p/7599124.html

總結

以上是生活随笔為你收集整理的作业7的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。