英文字符頻率統計。編寫一個程序,對給定字符串中出現的 a~z 字母頻率進行分析,忽略大小寫,採用降序方式輸出

txt = input("請輸入一段英文文本:") txt = txt.lower() d = {} for i in txt: if i in "abcdefghijklmnopqrstuvwxyz": d[i] = d.get(i,0) + 1 # 字典中的值 ls = list(d.items())
相關文章
相關標籤/搜索