0 python syntax-error python-2.7
我试图在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()
Run Code Online (Sandbox Code Playgroud)
你错过了raw_input()一行的结尾括号吗?
更改
input = raw_input("Type 1 for encryption, 2 for decryption, or 3 for information."
Run Code Online (Sandbox Code Playgroud)
至
input = raw_input("Type 1 for encryption, 2 for decryption, or 3 for information.")
Run Code Online (Sandbox Code Playgroud)