环境:windows10,Python3.6 代码: uh = input('Enter hours:') try: if float(uh) > 0: hour = float(uh) except: print('Error1, please enter numeric input.') quit() ur = input('Enter rate:') try: if float(ur) > 0: rate = float(ur) except: print("Error2, please enter numeric input.") quit() pay = hour * rate print(pay) 该代码在输入数字和字符串的时候都能够正常运行,但是如果输入0或者负数,则不会出现错误提示,而是出现如下报错,请问下各位究竟是哪里出问题了? |