Python: Catch multiple exceptions in one line (except block)

Enclose in parentheses:

1
2
except (IDontLIkeYouException, YouAreBeingMeanException) as e:
    pass

Separating the exception from the variable with a comma will still work in Python 2.6 and 2.7, but is now deprecated; now you should be using as.

posted @   紫红的泪  阅读(613)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示