8

在 Python 2.6+ 中,您可以像这样处理异常:

  try:
    # stuff
  except Exception as e:
    return 'exception %s' % type(e)

2.5中的等价物是什么?

4

1 回答 1

13

像这样 :

try:
    # stuff
except Exception, e:
  return 'exception %s' % type(e)
于 2011-05-25T14:34:47.600 回答