當我試圖運行這個它說NameError:名字「加密」沒有定義。Python的NameError:名字「加密」沒有定義
MAX_KEY_SIZE = 26
def getMode():
while True:
print('Do you wish to encrypt or decrypt a message?')
mode = input().lower()
if mode in "encrypt" 'e' 'decrypt' 'd'.split():
return mode
else:
print('Enter either "encrypt" or "e" or "decrypt" or "d".')
你使用Python 2還是Python 3?'print'函數看起來像3,但是你得到的'NameError'會來自2的'input'版本。 (請參閱[progo的答案](https://stackoverflow.com/questions/38631474/38631721#38631721)爲什麼它很重要。) –
看起來,這是Python 2代碼,帶'from __future__ import print_function' isn' t顯示在這裏。 –