【发布时间】:2018-02-25 00:13:05
【问题描述】:
在使用most_common 函数后,我需要帮助查找如何将字符串中最常见的字母打印为字符。我的代码是:
from collections import*
message = input("What is the message you would like to decrypt?")
messageInt = list(map(ord,list(message)))
messageChr = list(map(chr,list(messageInt)))
print messageChr
fre = Counter(messageChr)
mostLett = fre.most_common(1)
print mostLett
如何打印:
['e', 'x', 'a', 'm', 'p', 'l', 'e']
[('e', 2)]
e
【问题讨论】:
-
你使用的是 Python2 还是 Python3?
-
print 不是他代码中的函数,所以我假设 python2
标签: python list slice libraries