解密这个怎么做 帮看看

img


是要用列表吧,我学的不是很好。能给我点思路 代码啥的不 求帮看。

给个简单的例子,你参考看看吧,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)

img

根据题目:

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是已知的还是未知的?