用户:敷衍学家查看:5 回复:8 评论:5 创建时间:2020-06-25T18:18:43
while True:
x = list(input(""))
try:
x1 = x.index("*")
except:
try:
x1 = x.index("-")
except:
try:
x1 = x.index("+")
except:
try:
x1 = x.index("/")
except:
print("输入错误")
x2 = x[x1-1::-1]
x3 = x2[::-1]
x4 = x[x1+1::]
x5 = x[x1]
try:
x6 = int("".join(x3))
x7 = int("".join(x4))
except:
x6 = float("".join(x3))
x7 = float("".join(x4))
if x5 == "+":
print("{}+{}={}".format(x6,x7,x6 + x7))
elif x5 == "-":
print("{}-{}={}".format(x6,x7,x6 - x7))
elif x5 == "*":
print("{}*{}={}".format(x6,x7,x6 * x7))
elif x5 == "/":
print("{}/{}={}".format(x6,x7,x6 / x7))