未调用JavaScript处理程序。 在下面的代码中,Firefox无法运行(最新版本)。但是,它在Google Chrome浏览器中可以正常工作
alphabet =['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
def caesar(plaintext,shift):
# initialize ciphertext as blank string
ciphertext = ""
# loop through the length of the plaintext
for i in range(len(plaintext)):
# get the ith letter from the plaintext
letter = plaintext[i]
# find the number position of the ith letter
num_in_alphabet = alphabet.index(letter)
print (num_in_alphabet)
# find the number position of the cipher by adding the shift
cipher_num = (num_in_alphabet + shift + 3) % len(alphabet)
# find the cipher letter for the cipher number you computed
cipher_letter = alphabet[cipher_num]
# add the cipher letter to the ciphertext
ciphertext = ciphertext + cipher_letter
# return the computed ciphertext
return ciphertext
def main():
plaintext = ("hello")
shift = 16
text = caesar(plaintext,shift)
print (text)
main()