期末综合
Posted kaeo
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了期末综合相关的知识,希望对你有一定的参考价值。
#1. geciFile = open(‘geci.txt‘,mode="r",encoding=‘utf-8‘) geciText = geciFile.read() geciFile.close() print(geciText) #2. replaceList = [‘,‘,‘.‘,"‘",‘ ‘] for c in replaceList: geciText = geciText.replace(c,‘ ‘) print(geciText) #3. print(geciText.split(‘ ‘)) geciList = geciText.split(‘ ‘) #4. geciSet = set(geciList) print(geciSet) geciDict = {} for word in geciSet: geciDict[word] = geciList.count(word) print(geciDict) for d in geciDict: print(d,geciDict[d]) #5. wordCountList = list(geciDict.items()) print(wordCountList) wordCountList.sort(key=lambda x:x[1],reverse=True) print(wordCountList) #6. for i in range(20): print(wordCountList) #7. geciCountFile = open(‘geciCount.txt‘,mode=‘a‘,encoding=‘utf-8‘) for i in range(len(wordCountList)): geciCountFile.write(str(wordCountList[i][1])+‘ ‘+wordCountList[i][0]+‘ ‘) geciCountFile.close()
以上是关于期末综合的主要内容,如果未能解决你的问题,请参考以下文章
HTML5期末大作业:餐饮美食网站设计——咖啡(10页) HTML+CSS+JavaScript 学生DW网页设计作业成品 web课程设计网页规划与设计 咖啡网页设计 美食餐饮网页设计...(代码片段