world统计用python实现的方法,worldpython,python实现统计wo
world统计用python实现的方法,worldpython,python实现统计wo
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]
编橙之家文章,
相关内容
- 用Python语言打印杨辉三角形方法示例,python杨辉,下面这
- python猜数字游戏快速求解解决方案,python猜数字求解
- python计算文字的Md5和Sha1的校验值,,Python完成计算文字
- Python方法完成农历日历功能代码,python农历,Python方法完
- Python编写的点灯小游戏代码,python点灯小游戏,Python语言
- 日期查询软件python源代码,日期查询python,用python语言编
- Python 完成IE调用的示例源码分享,python示例,Python 完成
- Python是如何完成数据导入的,python完成数据导入,想知道
- 一个简易的Python封装的FTP功能,python封装ftp,这是一个简
- 基于Python的词典功能之爱词霸示例,python词霸,基于Py
评论关闭