题解 | #字符串加解密#
字符串加解密
http://www.nowcoder.com/practice/2aa32b378a024755a3f251e75cbf233a
def jiami(mima):
a = []
for i in mima:
if i == 'Z':
i = 'a'
elif i == 'z':
i = 'A'
elif i.isalpha() and i.islower():
i = chr(ord(i)+1).upper()
elif i.isalpha() and i.isupper():
i = chr(ord(i)+1).lower()
elif i == '9':
i = '0'
elif 0 <= int(i) < 9:
i = str(int(i)+1)
else:
i=i
a.append(i)
return a
def jiemi(mima1):
b = []
for i in mima1:
if i == 'a':
i = 'Z'
elif i == 'A':
i = 'z'
elif i.isalpha() and i.islower():
i = chr(ord(i)-1).upper()
elif i.isalpha() and i.isupper():
i = chr(ord(i)-1).lower()
elif i == '0':
i = '9'
elif 0 < int(i) <= 9:
i = str(int(i)-1)
else:
i=i
b.append(i)
return b
mima=input()
mima1=input()
print(''.join(jiami(mima)))
print(''.join(jiemi(mima1)))