题解 | #字符串加密#

字符串加密

http://www.nowcoder.com/practice/e4af1fe682b54459b2a211df91a91cf3

Python 代码实现:

while True:
    try:
        key = input().upper()
        string = input()
        alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
        encrypted_map = []
        res = ''
        for i in range(len(key)):
            if key[i] not in encrypted_map:
                encrypted_map.append(key[i])
        for j in alpha:
            if j not in encrypted_map:
                encrypted_map.append(j)
        for k in string:
            if k.islower():
                res += encrypted_map[alpha.index(k.upper())].lower()
            else:
                res += encrypted_map[alpha.index(k.upper())]
        print(res)
    except:
        break
全部评论
为啥要变大再变小?
点赞 回复 分享
发布于 03-26 22:22 上海

相关推荐

点赞 评论 收藏
分享
评论
15
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务