我尝试在Python 2.7上编写简单的加密程序时遇到了极其令人沮丧的错误。基本上它通过说我的语法无效而拒绝if / else语句,我不知道我做错了什么。 :在if输入==" 1":语句中,Python突出显示为不正确。
#Main menu function, directs user to an operation
def menu():
input = raw_input("Type 1 for encryption, 2 for decryption, or 3 for information."
if input == "1":
print "Encryption selected..."
encrypt()
elif input == "2":
print "Decryption selected..."
decrypt()
elif input == "3":
print "Loading info..."
info()
else:
print "ERROR: INVALID INPUT"
menu()
答案 0 :(得分:5)
您在raw_input()
行的末尾错过了结束括号?
更改
input = raw_input("Type 1 for encryption, 2 for decryption, or 3 for information."
到
input = raw_input("Type 1 for encryption, 2 for decryption, or 3 for information.")