这是我一直在从事的Caesar密码程序,我想知道是否有一种方法可以使它不只是输出“。”。而是更改它。现在,它只输出末尾带有标点符号的字母。
import collections
import string
from collections import deque
def caesar(rotate_string, number_to_rotate_by):
upper = collections.deque(string.ascii_uppercase)
lower = collections.deque(string.ascii_lowercase)
upper.rotate(number_to_rotate_by)
lower.rotate(number_to_rotate_by)
upper = ''.join(list(upper))
lower = ''.join(list(lower))
return rotate_string.translate(str.maketrans(string.ascii_uppercase, upper)) .translate(str.maketrans(string.ascii_lowercase, lower))
our_string= input("What would you like to translate?" )
for i in range(len(string.ascii_uppercase)):
print (i, "|", caesar(our_string, i))