[英]Why does my term show up as undefined in python?
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”是什么。 为什么会出错? 在原始代码中,最后一行中的术语只是“密钥”,因此我对其进行了更改,因为我认为这意味着将使用unencryptionKey,并认为将其绑定到第一行将允许它运行。 我尝试截屏,以便包含行号,但是行不通,因此必须剪切并粘贴。
似乎unencryptionKey
不是在全局范围内定义的,而是在某些函数中定义的。 删除unencryptionKey
之前的空格,它应与def passwordunEncrypt
处于同一级别
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.