题目内容
以下程序的功能是: s = "What’s a package, project, or release?We use a number of terms to describe software available on PyPI, like project, release, file, and package Sometimes those terms are confusing because they’re used to describe different things in other contexts Here’s how we use them on PyPI:A project on PyPI is the name of a collection of releases and files, and information about them Projects on PyPI are made and shared by other members of the Python community so that you can use themA release on PyPI is a specific version of a project For example, the requests project has many releases, like requests 210 and requests 121 A release consists of one or more filesA file, also known as a package, on PyPI is something that you can download and install Because of different hardware, operating systems, and file formats, a release may have several files (packages), like an archive containing source code or a binary wheel" s = s.lower() for ch in '’,?: ()': s = s.replace(ch," ") words = s.split() counts = {} for word in words: counts[word] = counts.get(word,0)+1 items = list(counts.items()) items.sort(key=lambda x:x[1],reverse = True) fo = open("wordnum.txt","w",encoding ="utf-8") for i in range(10): word,count = items[i] fo.writelines( word + ":" + str(count) + "\n") fo.close()
查看答案
搜索结果不匹配?点我反馈
更多问题