python2:
try:
..............
except Exception, e:
.........
python3:
try:
..............
except Exception as e:
.........
本文介绍了Python2和Python3中处理异常的不同语法。在Python2中,使用'except Exception, e'来捕获异常;而在Python3中,则使用'except Exception as e'。了解这些差异对于跨版本编程至关重要。
python2:
try:
..............
except Exception, e:
.........
python3:
try:
..............
except Exception as e:
.........
1万+
3970