开发者

How do you assign an exception to a local variable in Python 2.5?

开发者 https://www.devze.com 2023-03-08 03:12 出处:网络
In Python 2.6+, you can handle exceptions like this: try: # stuff except Exception as e: re开发者_JAVA百科turn \'exception %s\' % type(e)

In Python 2.6+, you can handle exceptions like this:

  try:
    # stuff
  except Exception as e:
    re开发者_JAVA百科turn 'exception %s' % type(e)

What is the equivalent in 2.5?


Like this :

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

精彩评论

暂无评论...
验证码 换一张
取 消