Python教程

python文件

本文主要是介绍python文件,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
 
s=input()
s= s.lower()
words =str(s)
counts ={}
for word in words:
    counts[word] = counts.get(word,0)+1
print(counts)

 

n= int(input())
txt =''
for i in range(n):
    s=input()
    txt += s
    txt = txt +' '
txt = txt.lower()
for ch in '!"#$%&()*+,-./:;<=>?@[\\]^_{|}~`0123456789':
    txt =txt.replace(ch,"")
words = txt.split()
counts ={}
for word in words:
    counts[word] =counts.get(word,0)+1
items =list(counts.items())
items.sort()
for i in range(len(items)):
    print("{} {}".format((items[i])[0],(items[i])[1]))

 

这篇关于python文件的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!