题解 | #字符串加解密#
字符串加解密
https://www.nowcoder.com/practice/2aa32b378a024755a3f251e75cbf233a
while True: try: s0 = list(input()) s1 = list(input()) for i in range(len(s0)): if s0[i].isupper(): if s0[i] == 'Z': s0[i] = 'a' else: s0[i] = chr(ord(s0[i]) + 33) elif s0[i].islower(): if s0[i] == 'z': s0[i] = 'A' else: s0[i] = chr(ord(s0[i]) - 31) elif s0[i].isdigit(): if s0[i] == '9': s0[i] = '0' else: s0[i] = chr(ord(s0[i]) + 1) for i in range(len(s1)): if s1[i].isupper(): if s1[i] == 'A': s1[i] = 'z' else: s1[i] = chr(ord(s1[i]) + 31) elif s1[i].islower(): if s1[i] == 'a': s1[i] = 'Z' else: s1[i] = chr(ord(s1[i]) - 33) elif s1[i].isdigit(): if s1[i] == '0': s1[i] = '9' else: s1[i] = chr(ord(s1[i]) - 1) print(''.join(s0)) print(''.join(s1)) except: break