unencryptionKey = (-16)
# Caesar Cypher Encryption
def passwordunEncrypt(encryptedMessage, key):
# We will start with an empty string as our encryptedMessage
encryptedMessage = ''
# For each symbol in the unencryptedMessage we will add an encrypted symbol into the encryptedMessage
for symbol in 'encryptedMessage':
if symbol.isalpha():
num = ord(symbol)
num += unencryptionKey
当我运行上面的代码时,它告诉我,在最后一行,“unencryptionKey”是未定义的。在第一行中,它确切地显示了“unencryptionKey”是什么。为什么会出错?在最初的代码中,最后一行中的术语只是“key”,所以我修改了它,因为我假设它们的意思是要使用unencryptionKey,并认为将它绑定到第一行将允许它运行。我试图截图,以便行号将包括在内,但它没有工作,所以必须剪切和粘贴
似乎
unencryptionKey
不是在全局范围内定义的,而是在某些函数中定义的。删除unencryptionKey
之前的空格,它应该与def passwordunEncrypt
处于同一级别相关问题 更多 >
编程相关推荐