我目前正在阅读tutorialspoint的python教程中的教程。但这是Python 2的教程,而不是我现在拥有的Python 3.3。好吧,我设法在互联网上搜索并发现了一些变化。但是这一步相当艰难。
因此,在tutorialspoint中,引发异常的python源代码为:
def functionName( level ):
if level < 1:
raise "Invalid level!", level
# The code below to this would not be executed
# if we raise the exception
但是如果我输入
raise "Invalid level!", level
它说语法错误。因此,我想知道如何在Python 3.3中引发异常。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句