题解 | #字符串加解密#
字符串加解密
https://www.nowcoder.com/practice/2aa32b378a024755a3f251e75cbf233a
digi = {} zimu = {} k = ['0','1','2','3','4','5','6','7','8','9'] v = ['1','2','3','4','5','6','7','8','9','0'] digi = dict(zip(k,v)) # print(digi) k = list('abcdefghijklmnopqrstuvwxyz') v = list('BCDEFGHIJKLMNOPQRSTUVWXYZA') zimu = dict(zip(k,v)) # print(zimu) def jiemi(x, dic): for k, v in dic.items(): if x == v: return k str1 = input() str2 = input() for i in str1: if i.isdigit(): print(digi[i],end='') elif 'a'<= i <='z': print(zimu[i],end='') else: print(zimu[i.lower()].lower(),end='') print() for i in str2: if i.isdigit(): print(jiemi(i,digi),end='') elif 'a'<= i <= 'z': print(jiemi(i.upper(),zimu).upper(),end='') else: print(jiemi(i.upper(),zimu),end='')