python异常
while True : try: x = raw_input("Enter the first number : ") y = raw_input("Enter the second number : ") value = x/y print "x/y is ", value except : print "something wrong , please try again " else : break
#!python# encoding: utf-8import syserrStream = sys.stderroutStream = sys.stdoutdef getInt(): while True: try: n = int(raw_input('Enter an integer number:')) except: errStream.write('integer input error, try again\n') continue return ndef main(): while True: x = getInt() y = getInt() try: outStream.write('%d / %d is %d\n'%( x, y, x/y)) except: errStream.write('some error in div, try again\n') else: breakif __name__ == '__main__': main()