欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Python(十三)异常

程序员文章站 2022-06-08 10:13:48
...

异常及异常处理

 

try://执行第一步

    #int("hello world")

    int(123)

except (ValueError, TypeError) as reason://捕获异常

    print("出错啦:" + str(reason))

else://如果没有异常执行else

    print("执行正常")

finally://最终肯定要执行,除非程序提前退出

    print("finally exit...") 


Python(十三)异常
            
    
    博客分类: python
 

    with语句***

  • Python(十三)异常
            
    
    博客分类: python
  • 大小: 23.5 KB