def sum(a,b):
print('=%d' % (a+b))
def reduction(a,b):
print('=%d' % (a-b))
def multiplication(a,b):
print('=%d' % (a*b))
def division(a,b):
print('=%f' % (a/b))
def aliquot(a,b):
print("=%d" % (a//b))
def morethan(a,b):
print("=%d" % (a%b))
judge = 1
while judge:
re = input()
if '+' in re:
a = int(re.split('+'))
b = int(re.split('+'))
sum(a, b)
elif '-' in re:
a = int(re.split('-'))
b = int(re.split('-'))
reduction(a, b)
elif '*' in re:
a = int(re.split('*'))
b = int(re.split('*'))
multiplication(a, b)
elif '//' in re:
a = int(re.split('//'))
b = int(re.split('//'))
aliquot(a, b)
elif '/' in re:
a = float(re.split('/'))
b = float(re.split('/'))
division(a, b)
elif '%' in re:
a = int(re.split('%'))
b = int(re.split('%'))
morethan(a, b)
elif re=='Q' or re=='q':#这里不对,re='Q'or'q'永远为true
break
else:
print("输入有误,请重新输入...")
continue
re == 'Q' or 'q'
等价于,re =='Q' or 1
等价于 1
所以你输入的除了加减乘除之外的所有情况全部被break掉了
页:
[1]