此代码的问题是if / elif / else的语法错误。但我不知道为什么它会向我显示错误。
try:
if ans_three = '+':
x = add(ans_one,ans_two)
print("[+] Your Total Number: " + x)
elif ans_three = '-':
x = minus(ans_one, ans_two)
print("[-] Your Total Number: " + x)
elif ans_three = '*':
x = minus(ans_one, ans_two)
print("[*] Your Total Number: " + x)
elif ans_three = '/':
x = minus(ans_one, ans_two)
print("[/] Your Total Number: " + x)
else:
print('>> Wrong operators! [+] [-] [*] [/]')
except ValueError:
print("Invalid Number!")
StopIteration
这是错误:
if ans_three = '+':
^
SyntaxError: invalid syntax
Process finished with exit code 1
我使用的软件是:
PyCharm Community Edition 2017.1.3