python基础教程笔记(chapt.8) 异常

2018-08-03  本文已影响6人  JuneZhu_870a
常见内建异常

创建异常:
class SomeCustomException(Exception): pss

捕捉异常

x=input('Enter the first number: ')
y=input('Enter the second number: ')
print x/y
##################
try:
    x=input('Enter the first number: ')
    y=input('Enter the second number: ')
    print x/y
except ZeroDivisionError:
    print "The second number can't be zero!"
上一篇 下一篇

猜你喜欢

热点阅读