题解 | #字符串加解密#

字符串加解密

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)))
    
全部评论

相关推荐

不愿透露姓名的神秘牛友
11-29 12:19
点赞 评论 收藏
分享
点赞 评论 收藏
分享
object3:开始给部分🌸孝子上人生第一课了
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务