题解 | #字符串加解密#

字符串加解密

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-27 17:08
已编辑
牛客_产品运营部_私域运营
腾讯 普通offer 24k~26k * 15,年包在36w~39w左右。
点赞 评论 收藏
分享
贪食滴🐶:你说熟悉扣篮的底层原理,有过隔扣职业球员的实战经验吗
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务