[英]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.