python实现统计word的小程序,pythonword小程序,[Python]代码Py
python实现统计word的小程序,pythonword小程序,[Python]代码Py
[Python]代码
Python语言: python实现统计word的小程序# -*- coding:utf-8 -*- import redef mycmp (x,y): if x[1] > y[1]: return 1 elif x[1] < y[1]: return -1 else: if x[0] > y[0]: return -1 elif x[0] ==y[0]: return 0 else: return 1file = open("word.py")text = file.read()wordList = str.split(re.sub(r'\W|\d',' ',text))wordList= zip(set(wordList),map(lambda x:wordList.count(x),set(wordList)))wordList.sort(reverse=True,cmp=mycmp)for word in wordList: print word[0],":",word[1]
相关内容
- HTML颜色和RGB颜色互转,html颜色rgb,[Python]代码Py
- 常见的Python字符串操作和一下小技巧,python字符串,[P
- python中获取按键(跨平台),python获取按键,[Python]代码P
- Python将内容中的Url地址转换成Tinyurl地址,pythontinyurl,
- 计算今天是一年中的第几周,计算一年第几周,[Python]代
- 多线程下载地址检测url_download,多线程url_download,#!/us
- 求素数的快速算法,素数算法,[Python]代码Py
- 组合生成与数量计算(Combinaton generator and counter),,[Pyt
- 生成华容道所有可求解的开局含镜像263977种,不含镜像
- 从NCBI下载基因序列,NCBI下载基因序列,[Python]代码Py
评论关闭