题解 | #字符串加密#
字符串加密
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))