在下面的 python 中,不会打印消息 RSU is not support on single node machine**。有人可以帮忙吗??
#! /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)
最佳答案
它没有被打印,因为你甚至没有尝试打印它:)这里:
try:
isPrepActionNeeded()
except RSUNotSupported as e:
print str(e)
sys.exit(1)
关于python 异常处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7022148/