在Python 2.6+中,您可以像这样处理异常:
try:
# stuff
except Exception as e:
return 'exception %s' % type(e)
2.5版本中的等价物是什么?
try:
# stuff
except Exception as e:
return 'exception %s' % type(e)
2.5版本中的等价物是什么?
str()
,因为你已经在使用%s
进行插值了,'exception %s' % type(e)
会很好地工作。 - mouad