6.20
Posted whyyxxx
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了6.20相关的知识,希望对你有一定的参考价值。
qFile = open("q.txt",mode="r",encoding=‘utf-8‘) qText = qFile.read() qFile.close() print(qText) replaceList = [‘,‘,‘.‘,"‘",‘ ‘] for c in replaceList: qText = qText.replace(c,‘ ‘) print(qText) print(qText.split(‘ ‘)) qList = qText.split(‘ ‘) qSet = set(qList) print(qSet) qDict = {} for word in qSet: qDict[word] = qList.count(word) print(qDict) for d in qDict: print(d,qDict[d]) wordCountList = list(qDict.items()) print(wordCountList) wordCountList.sort(key=lambda x:x[1],reverse=True) print(wordCountList) for i in range(20): print(wordCountList) qCountFile = open(‘qCount.txt‘,mode=‘a‘,encoding=‘utf-8‘) for i in range(len(wordCountList)): qCountFile.write(str(wordCountList[i][1])+‘ ‘+wordCountList[i][0]+‘ ‘) qCountFile.close()
以上是关于6.20的主要内容,如果未能解决你的问题,请参考以下文章
开发实践教程1:试卷生成系统6.20 密码修改(FormPass)