题解 | #字符串加密#
字符串加密
https://www.nowcoder.com/practice/e4af1fe682b54459b2a211df91a91cf3
import sys inp = sys.stdin.readlines() key = inp[0].strip() s = inp[1].strip() new_key = '' se = set() for c in key: if c not in se: new_key += c se.add(c) for c in 'abcdefghijklmnopqrstuvwxyz': if c not in new_key: new_key += c res = '' for c in s: index = ord(c)-ord('a') res += new_key[index] print(res)