题解 | 字符串加解密
import sys encode = input() #加密 decode = input() type_encode = 1 type_decode = -1 def deel_code(strs, type_kind): ret = '' for i in strs: if i.isalpha(): if i.isupper(): ret += chr((ord(i.lower()) + type_kind - ord('a')) % 26 + ord('a')) else: ret += chr((ord(i.upper()) + type_kind - ord('A')) % 26 + ord('A')) if i.isdigit(): ret += str((int(i) + type_kind) % 10) return ret print(deel_code(encode, type_encode)) print(deel_code(decode, type_decode))