Python代码
def func():
try:
n1 = int(input("Please input the firest one:"))
n2 = int(input("Please input the secend one:"))
per = input("Please input + - * /")
result = 0
if per == '+':
result = n1 + n2
elif per == '-':
result = n1 - n2
elif per == '*':
result = n1 * n2
elif per == '/':
result = n1 / n2
else:
print('输入有误!!')
print('result is:', result)
except ZeroDivisionError:
print('You must input int type.')
except ValueError:
print('Must input int type')
func()
版权声明:本文为博主原创文章,未经博主允许不得转载。
Python