def apply_shift(self, shift):
'''
Applies the Caesar Cipher to self.message_text with the input shift.
Creates a new string that is self.message_text shifted down the
alphabet by some number of characters determined by the input shift
shift (integer): the shift with which to encrypt the message.
0 <= shift < 26
Returns: the message text (string) in which every character is shifted
down the alphabet by the input shift
'''
letters_all = string.ascii_lowercase + string.ascii_uppercase
shifted_txt = ''
shift_dic = self.build_shift_dict(shift)
for e in self.message_text:
if e in letters_all:
e = shift_dic[e]
shifted_txt += e
return shifted_txt
ps6.py 文件源码
python
阅读 33
收藏 0
点赞 0
评论 0
评论列表
文章目录