以下のpythonでは、メッセージRSUはシングルノードマシン**ではサポートされていません**は印刷されません。誰でも助けてくれる?Python例外処理
#! /usr/bin/env python
import sys
class SWMException(Exception):
def __init__(self, arg):
print "inside exception"
Exception.__init__(self, arg)
class RSUNotSupported(SWMException):
def __init__(self):
SWMException.__init__(self, "**RSU is not supported on single node machine**")
def isPrepActionNeeded():
if 1==1:
raise RSUNotSupported()
try:
isPrepActionNeeded()
except:
sys.exit(1)
例外.__ init __(self、arg) このinit呼び出しのarg引数は何ですか?それはメッセージを印刷しません – mandeep
メッセージを例外の一部にするため、後で自分で印刷することができます。 – agf
よ、そうです。どうもありがとう。それは本当に役立った – mandeep