#老夫写代码就是列表一把梭,不要跟我说什么元组字典集合 a=[chr(i) for i in range(65,65+26)]#大写字母,注意range取头不取尾 b=[chr(i) for i in range(48,48+10)]#数字 c=[chr(i) for i in range(97,97+26)]#小写字母 #加密函数: def encode(s): global a,b,c s1="" for i in s: if i.isalpha():#字母 if i.upper()==i:#大写 s1+=c[(a.index(i)+1)%26] else: s1+=a[(c.index(i)+1)%26] elif i.isnumeric(): s1+=b[(b.index(i)+1)%10] else: s1+=i return s1 #解密函数 def decode(s): global a,b,c s1="" for i in s: if i.isalpha(): if i.upper()==i:#大写 s1+=c[(a.index(i)-1+26)%26] else: s1+=a[(c.index(i)-1+26)%26] elif i.isnumeric(): s1+=b[(b.index(i)-1+10)%10] else: s1+=i return s1 s1=input() s2=input() print(encode(s1)) print(decode(s2)) #写完之后才想起来,连开头的三个列表都可以不用的 #直接操作ascii码即可