题解 | 字符串加解密
字符串加解密
https://www.nowcoder.com/practice/2aa32b378a024755a3f251e75cbf233a
import sys s = input() t = input() slen = len(s) tlen = len(t) s1 = '' t1 = '' while True: try: for i in range(slen): if s[i].isalpha() == 1: if s[i] >= "A" and s[i] < 'Z': s1 += chr(ord(s[i])+33) elif s[i] == 'Z': s1 += 'a' elif s[i] >= "a" and s[i] < 'z': s1 += chr(ord(s[i])-31) elif s[i] == 'z': s1 += 'A' elif s[i].isdigit() == 1: num = int(s[i]) if num >= 0 and num < 9: s1 += str(num+1) elif num == 9: s1 += '0' print(s1) for i in range(tlen): if t[i].isalpha() == 1: if t[i] > "A" and t[i] <= 'Z': t1 += chr(ord(t[i])+31) elif t[i] == 'A': t1 += 'z' elif t[i] > "a" and t[i] <= 'z': t1 += chr(ord(t[i])-33) elif t[i] == 'a': t1 += 'Z' elif t[i].isdigit() == 1: num = int(t[i]) if num > 0 and num <= 9: t1 += str(num-1) elif num == 0: t1 += '9' print(t1) except: print(0) break