给个简单的例子,你参考看看吧,code的内容根据题目反推出来几位,其它的可以随意定义:
code = ('g','K','a','P','b','x','d','f','w','t')
while True:
ciphertext = input("请输入欲解密的密文(输入字母q退出):")
if ciphertext=='q':
break
text = ''
for c in ciphertext:
if c in code:
text = text+str(code.index(c))
else:
text = text +'?'
print("解码结果为:")
print(text)
根据题目:
agKxKaKa
20151212
agKxKgPKAk
20151031??
a = 2
g = 0
K = 1
x = 5
P = 3
K = 1
A = ?
k = ?
0 1 2 3 4 5 6 7 8 9
g K a P ? x ? ? ? ?
其他的数目没有,可能需要自己设定,不要使用重复的。
元组code是已知的还是未知的?