这是一个简单加密方法的代码。
if character in alphabet:
position=alphabet.find(character)
newPosition=(position-key)%26 # here
newCharacter=alphabet[newPosition]
print("The encrypted character is: " + newCharacter)
newMessage += newCharacter
print(newMessage)
答案 0 :(得分:3)
代码中的%
符号是 modulo 运算符 - 整数除法后的余数。 E. g。
13 % 5
给出结果3
(13
除以5
为2
,其余为3
。