题解 | #字符串加密#

字符串加密

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

# 密钥 :TRAILBLAZERS
#顶 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
#取 T R A I L B Z E S C D F G H J K M N O P Q U V W X Y
# Attack AT DAWN (黎明时攻击)
# Tpptad TP ITVH
key = input().lower()
mimabiao = []
mingwen = input()
zimubiao = 'abcdefghijklmnopqrstuvwxyz'
res = []
# 去重
for i in key:
    if i not in mimabiao:
        mimabiao.append(i)
#print(ls)
for j in zimubiao:
    if j not in mimabiao:
        mimabiao.append(j)

for k in mingwen:
    if k.isupper():
        res.append(mimabiao[zimubiao.index(k.islower())])
    elif k.islower():
        res.append(mimabiao[zimubiao.index(k)])
    else:
        res.append(k)
        
        
print(''.join(res)) 

全部评论

相关推荐

10-27 17:26
东北大学 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务