Python 解析时出现意外的EOF???
所以我试图创建一个简单的计算器,我认为这段代码没有任何错误,但当我运行代码时,它说有语法错误:在解析([字符串],第1行)时出现意外的EOF,我尝试了一些更改,但我仍然看不到错误,请帮助我Python 解析时出现意外的EOF???,python,Python,所以我试图创建一个简单的计算器,我认为这段代码没有任何错误,但当我运行代码时,它说有语法错误:在解析([字符串],第1行)时出现意外的EOF,我尝试了一些更改,但我仍然看不到错误,请帮助我 operation = input ("Pick your operation: + | - | * | / ") if operation == '+' : no1 = int(input ("Pick a number")) no2 = int(
operation = input ("Pick your operation: + | - | * | / ")
if operation == '+' :
no1 = int(input ("Pick a number"))
no2 = int(input ("Pick another number"))
answer = no1 + no2
print ( "Answer:", no1 , "+" , no2 , "=", answer)
elif operation == '-':
no1 = int(input ("Pick a number"))
no2 = int(input ("Pick another number"))
answer = no1 - no2
print ( "Answer:", no1 , "-" , no2 , "=" , answer)
elif operation == '*':
no1 = int(input ("Pick a number"))
no2 = int(input ("Pick another number"))
answer = no1 * no2
print ( "Answer:", no1 , "*" , no2 , "=", answer)
elif operation == '/':
no1 = int(input ("Pick a number"))
no2 = int(input ("Pick another number"))
answer = no1 / no2
print ( "Answer:", no1 , "/" , no2 , "=", answer)
else:
print ("Please check your given options of operations.")
您的行在Python2和Python3中都有效,但仅在Python3中才有意义 版本之间的输入行为发生了变化 在Python 2中,您必须使用
raw\u输入
:
operation = raw_input("Pick your operation: + | - | * | / ")
有关详细信息,请阅读和上的文档。对于python版本<3.0,您需要使用
raw\u input
。您可能需要检查Python的哪个版本,2或3?可能的副本