📅  最后修改于: 2022-03-11 14:57:20.529000             🧑  作者: Mango
def solution(s, n):
answer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' * (n + 1)
s = list(s)
for i in range(len(s)):
a = ord(s[i].upper())
if s[i] == ' ':
continue
if s[i] in answer:
s[i] = answer[(a + n) % 65]
else:
s[i] = answer[(a + n) % 65].lower()
return ''.join(s)