这是关于加密的
def encrypt(plain_text, shift_amount):
cipher_text = ""
for letter in plain_text:
position = alphabet.index(letter)
new_position = position + shift_amount
new_letter = alphabet[new_position]
cipher_text += new_letter
print(f"The encoded text is {cipher_text}")
我不懂def encrypt
的逻辑。非常感谢。我是Python新手。
例如,我不明白我们为什么要创建cipher_text
或者为什么要写position
我没有写代码的开头和结尾
完整的代码很可能与字母表列表类似,是实现Caesar Cipher的一个简单函数。我已经对下面的完整代码进行了注释,以解释每一行尝试执行的操作:
相关问题 更多 >
编程相关推荐