554544

#1
kkFile = open('kk.txt','r')
kkTest = kkFile.read()
kkFile.close()
print(kkTest)
#2
print(kkTest.replace(',',' '))
print(kkTest.replace("'",' '))
print(kkTest)
#3
print(kkTest.split(' '))
kkList = kkTest.split(' ')
#4
kkSet = set(kkList)
print(kkSet)
kkDict = {}
for word in kkSet:
kkDict[word] = kkList.count(word)
print(kkDict)
for d in kkDict:
print(d,kkDict[d])
wordCountList = list(kkDict.items())
print(wordCountList)
wordCountList.sort(key=lambda x:x[1],reverse=True
print(wordCountList)
for i in range(20):
print(wordCountList[1])

  

posted on 2018-06-11 17:04  rabbitank  阅读(180)  评论(0编辑  收藏  举报

导航