解法一
while True:
try:
expr = input()
for i in expr:
if i.isnumeric() or i == '.':
pass
else:
x, y = expr.split(i)
res = eval(expr)
print(f'{eval(x):.4f}{i}{eval(y):.4f}={res:.4f}')
except ZeroDivisionError as e:
print("Wrong!Division by zero!")
except SyntaxError as e:
print("Invalid operation!")
finally:
break
解法二
info = input()
if '+' in info:
a,b = list(map(float,info.split('+')))
print('%.4f+%.4f=%.4f'%(a,b,a+b))
elif '-' in info:
a,b = list(map(float,info.split('-')))
print('%.4f-%.4f=%.4f'%(a,b,a-b))
elif '*' in info:
a,b = list(map(float,info.split('*')))
print('%.4f*%.4f=%.4f'%(a,b,a*b))
elif '/' in info:
a,b = list(map(float,info.split('/')))
if b == 0:
print('Wrong!Division by zero!')
else:
print('%.4f/%.4f=%.4f'%(a,b,a/b))
else:
print('Invalid operation!')