Python 字符串统计:不同字符数量及出现次数
def Freq(line): count = {} for ch in line: if ch.isalnum(): count[ch] = count.get(ch, 0) + 1 print(len(count)) for ch in sorted(count.keys()): print(ch, '= ', count[ch]) line = input() Freq(line)
原文地址: https://www.cveoy.top/t/topic/orcm 著作权归作者所有。请勿转载和采集!