题解 | #字符串加解密#
字符串加解密
https://www.nowcoder.com/practice/2aa32b378a024755a3f251e75cbf233a
def jiami(string): res = "" for c in string: if c == "z": res += "A" elif c == "Z": res += "a" elif "a" <= c <= "z": res += chr(ord(c.upper()) + 1) elif "A" <= c <= "Z": res += chr(ord(c.lower()) + 1) elif "0" <= c < "9": res += chr(ord(c) + 1) elif c == "9": res += "0" return res def jiemi(string): res = "" for c in string: if c == "a": res += "Z" elif c == "A": res += "z" elif "a" <= c <= "z": res += chr(ord(c.upper()) - 1) elif "A" <= c <= "Z": res += chr(ord(c.lower()) - 1) elif "0" < c <="9": res += chr(ord(c) - 1) elif c == "0": res += "9" return res str1 = str(input()) str2 = str(input()) print(jiami(str1)) print(jiemi(str2))