def add(x, y):
c = x + y
print(c)
def sub(x, y):
c = x - y
print(c)
def multi(x, y):
c = x * y
print(c)
def div(x, y):
c = x / y
print(c)
def test(m):
if m == '1':
add(a, b)
elif m == '2':
sub(a, b)
elif m == '3':
multi(a, b)
elif m == '4':
div(a, b)
else:
print("Enter above menu")
print("1 add\n2 sub\n3 multi\n4 div\n")
n = input("Enter the option ")
a, b = input("Enter the numbers ").split()
test(n)
我得到的错误是文件“ C:/Users/HP/PycharmProjects/CALCULATOR/main.py”,第36行n =输入(“输入选项”)^IndentationError:意外缩进
请有人帮帮我
第36行上不应有空格。 Python对缩进很敏感,因此空格会导致错误。
删除n
之前的空格,然后重试。
只需缩进输入行,就可以了。在运行程序之前,请注意弹出的错误,这种情况将不会再次发生。