博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
词频统计
阅读量:5901 次
发布时间:2019-06-19

本文共 1768 字,大约阅读时间需要 5 分钟。

# -*- coding: UTF-8 -*-str = '''Gotta Have You  (The Weepies)Gray, quiet and tired and meanPicking at a worried seamI try to make you mad at me over the phoneRed eyes and fire and signsI'm taken by a nursery rhymeI want to make a ray of sunshine and never leave homeNo amount of coffeeNo amount of cryingNo amount of whiskeyNo amount of wineNo, nothing else will doI've gotta have youI've gotta have youThe road gets coldThere's no spring in the middle this yearI'm the new chicken clucking open hearts and earsOh, such a prima DonnaSorry for myselfBut green, it is also summerAnd I won't be warm till I'm lying in your armsNo amount of coffeeNo amount of cryingNo amount of whiskeyNo amount of wineNo, nothing else will doI've gotta have youI've gotta have youI see it all through a telescope:Guitar, suitcase, and a warm coatLying in the back of the blue boatHumming a tune...No amount of coffeeNo amount of cryingNo amount of whiskeyNo wineNo, nothing else will doI've gotta have youI've gotta have youNo amount of coffeeNo amount of cryingNo amount of whiskeyNo amount of wineNo, nothing else will doI've gotta have you ~~gotta have youI've gotta have you'''n='''~,.'"?!;)('''exclude = {
'the','a','of','to','for','in','and','no','i','you','ve','have'}for t in n: str = str.replace(t,' ')wordList = str.lower().split()wordDict = {}wordSet = set(wordList)for w in wordSet: wordDict[w] = wordList.count(w)for w in wordList: wordDict[w] = wordDict.get(w,0)+1for w in exclude: wordDict.pop(w)dictList = list(wordDict.items())dictList.sort(key=lambda x: x[1], reverse=True)for w in dictList: print(w)

f = open('C:\Users\Administrator\PycharmProjects\bd\so.txt','r')text = f.read()f.close()print(text)

 

转载于:https://www.cnblogs.com/0056a/p/8649901.html

你可能感兴趣的文章
沙盒目录介绍
查看>>
260. Single Number III
查看>>
Hadoop生态圈-Kafka的完全分布式部署
查看>>
[MODx] Build a CMP (Custom manager page) using MIGX in MODX 2.3 -- 1
查看>>
jQuery自动完成点击html元素
查看>>
[算法]基于分区最近点算法的二维平面
查看>>
webpack多页应用架构系列(七):开发环境、生产环境傻傻分不清楚?
查看>>
笨办法学C 练习1:启用编译器
查看>>
树的总结--树的性质(树的深度) leetcode
查看>>
nagios短信报警(飞信fetion20080522004-linrh4)
查看>>
【Android游戏开发之六】在SurfaceView中添加组件!!!!并且相互交互数据!!!!...
查看>>
linux 将大文件分成小文件
查看>>
CCNA- 距离矢量路由协议学习
查看>>
企业实践用户邮箱导入/导出(第2部分)
查看>>
如何学习Linux命令-初级篇
查看>>
从Oracle Public Yum为Oracle Linux建立本地的Yum源
查看>>
静态路由和默认路由
查看>>
关于阿里开发者招聘节 |这5道笔试真题 你会吗!???
查看>>
C#的异常处理机制
查看>>
vsftp:500 OOPS: could not bind listening IPv4 sock
查看>>