# Python CodeRecipe|raiseの使い方
❮ Home ❮ Python Keywords
# raiseの例1
Raise an error and stop the program if x is lower than 0:
x = -1if x < 0: raise Exception("Sorry, no numbers below
zero")
# raiseの定義及び使い方
raise関数は、 例外。 発生させるエラーの種類と、ユーザーに出力するテキストを定義できます。
# raiseの例2
Raise a TypeError if x is not an integer:
x = "hello"if not type(x) is int: raise TypeError("Only
integers are allowed")
❮ Home ❮ Python Keywords