密文是我用来打印重复字符及其出现百分比的字符串。这是代码:
def freq_attack (ciphertext):
store = ""
character = ""
non_character=""
for i in xrange(len(ciphertext)):
x = ciphertext[i]
if(is_alphabet(x)):
character +=x
else:
non_character +=x
for char in character:
count =(ciphertext.count(char)*100)/len(character)
print char, count,"%"
输出是
a 400/7 %
s 100/7 %
a 400/7 %
a 400/7 %
e 100/7 %
a 400/7 %
w 100/7 %