python3 与python2 异常处理的区别与联系
作者:hebedich 时间:2022-11-06 22:39:30
在python2.x中 ,异常是这样的处理的,异常基类后面加一个逗号“ ,” 然后跟着异常类型
import traceback
try:
1/0
except Exception , err:
print err
在python3.x中,异常是这样处理的,基类通过关键 词"as" 连接异常类型
import traceback
try:
1/0
except Exception as err:
print(err)
标签:python,异常处理
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
使用python实现三维图可视化
2021-07-31 02:28:57
![](https://img.aspxhome.com/file/2023/8/64278_0s.png)
详解Python中的日志模块logging
2021-11-24 21:58:34
![](https://img.aspxhome.com/file/2023/5/81545_0s.jpg)
Python 实现训练集、测试集随机划分
2023-02-12 01:41:24
![](https://img.aspxhome.com/file/2023/8/76898_0s.jpg)
python数据处理——对pandas进行数据变频或插值实例
2021-01-05 19:22:01
MySQL数据库对dvbbs.php全文搜索的完全分析
2010-06-11 13:25:00
打造设计你自己的字体
2007-12-12 13:16:00
![](https://img.aspxhome.com/file/UploadPic/200712/12/20071212132556860s.jpg)
使用pd.merge表连接出现多余行的问题解决
2023-08-25 11:34:24
![](https://img.aspxhome.com/file/2023/9/121879_0s.jpg)
Oracle数据库中的级联查询、级联删除、级联更新操作教程
2023-06-25 19:01:42
![](https://img.aspxhome.com/file/2023/4/63714_0s.png)
python中reduce()函数的使用方法示例
2021-08-09 12:32:53
![](https://img.aspxhome.com/file/2023/9/117969_0s.png)
python不同版本的_new_不同点总结
2023-09-21 15:36:45
python完成FizzBuzzWhizz问题(拉勾网面试题)示例
2022-01-31 14:41:11
Pycharm以root权限运行脚本的方法
2022-03-16 12:23:51
![](https://img.aspxhome.com/file/2023/0/107110_0s.jpg)
pycharm中连接mysql数据库的步骤详解
2024-01-19 22:22:40
![](https://img.aspxhome.com/file/2023/7/130987_0s.jpg)
深入了解mysql长事务
2024-01-28 10:29:32
Golang分布式应用定时任务示例详解
2024-02-12 06:23:19
![](https://img.aspxhome.com/file/2023/1/107361_0s.jpg)
python datetime 和时间戳互相转换问题
2023-12-31 05:32:26
详解MySQL中concat函数的用法(连接字符串)
2024-01-18 09:30:56
javascript 跳转代码集合
2024-04-19 10:42:40
Go语言编译原理之变量捕获
2024-04-27 15:27:14
![](https://img.aspxhome.com/file/2023/3/134213_0s.jpg)
一文带你吃透Python中的os和sys模块
2022-01-04 20:42:55
![](https://img.aspxhome.com/file/2023/0/76010_0s.png)