Python try-except异常语法。逗号(',')与'as'相同

时间:2012-01-31 18:15:58

标签: python syntax exception-handling try-catch

  

可能重复:
  Python try…except comma vs 'as' in except

这个问题非常基本,我很尴尬地问它。然而,我在网上或在我的python书中找到答案时遇到了麻烦,我希望我已经措辞好并标记了这个问题,以便其他人可以从答案中受益。

在python中,try-catch块看起来像这样:

try:
   do_Some_Stuff()
except ExceptionType as e:
   # Handle the error

我遇到了一些似乎有逗号而不是'as'的代码。这是一回事吗?

try:
   do_Some_Stuff()
except ExceptionType, e:  # <-- comma(',') instead of 'as' here
   # Handle the error

提前感谢不让我觉得太傻了!

0 个答案:

没有答案