码迷,mamicode.com
首页 > 其他好文 > 详细

异常和错误!

时间:2016-12-30 14:26:28      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:input   put   exce   else   bsp   --   异常   使用   one   

try:#使用try与except异常和错误!
    age=input(‘>>>‘) #用户输入
    int(age)
    num2 = input(‘>>>‘)
    int(num2)
    1[1000]
    dic = {}
    dic=[‘name‘]
except KeyboardInterrupt as e:
    print(e)
except ValueError as e:
    print(e)
except IndentationError as e:
    print(‘-------->‘,e)
except TypeError as e:
    print(e)
except Exception as e:
    print(e)
else:
    print("try 内码错误没有异常执行我")
finally:
    print(‘无论是否异常,都要执行我‘)
print(‘11111111111111111‘)

 

异常和错误!

标签:input   put   exce   else   bsp   --   异常   使用   one   

原文地址:http://www.cnblogs.com/huangjinshan/p/6236724.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!