
是要用列表吧,我学的不是很好。能给我点思路 代码啥的不 求帮看。
给个简单的例子,你参考看看吧,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)
