美文网首页
python基础教程笔记(chapt.8) 异常

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

作者: JuneZhu_870a | 来源:发表于2018-08-03 17:04 被阅读6次
常见内建异常

创建异常:
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!"

相关文章

网友评论

      本文标题:python基础教程笔记(chapt.8) 异常

      本文链接:https://www.haomeiwen.com/subject/spxfpxtx.html