如何用新型別重新引發 Python 異常?
在 Python 3.x 中,程式碼受異常鏈的影響,我們獲得的輸出如下所示
C:/Users/TutorialsPoint1/~.py Traceback (most recent call last): File "C:/Users/TutorialsPoint1/~.py", line 2, in <module> 1/0 ZeroDivisionError: division by zero
上述異常是導致以下異常的直接原因
Traceback (most recent call last): File "C:/Users/TutorialsPoint1/~.py", line 4, in <module> raise ValueError ( "Sweet n Sour grapes" ) from e ValueError: Sweet n Sour grapes
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP