59-异常1

try:   # 把有可能发生异常的语句放到try里执行
    n = int(input("number: "))
    result = 100 / n
    print(result)
except ValueError:
    print('invalid number')
except ZeroDivisionError:
    print('0 not allowed')
except KeyboardInterrupt:
    print('Bye-bye')
except EOFError:
    print('Bye-bye')

print('Done')
原文地址:https://www.cnblogs.com/hejianping/p/10948286.html