简体   繁体   English

Odoo 11中异常处理py代码的区别

[英]Difference in Exception handling py code in Odoo 11

What are differences in exception from the coding point of view in Odoo 11 as compared in Odoo 10? 从Odoo 11中的编码角度来看,与Odoo 10中的编码相比,异常有什么区别? Can't find other differences except except Exception, e: to except Exception as e: My code shows error somehow from exception while converting a module from Odoo 10 to Odoo 11. 除了Exception以外,找不到其他差异:e:Exception as e:我的代码在将模块从Odoo 10转换为Odoo 11时从某种程度上显示了错误。

In Python 2.5 and earlier versions, 'as' isn't supported, so you use except Exception, e: 在Python 2.5和更早版本中,不支持'as',因此您可以使用Exception除外,e:

In Python 2.6+ versions, both can be used. 在Python 2.6+版本中, 可以使用。

But from Python 3.x, except Exception as e is required to assign an exception to a variable. 但是从Python 3.x开始, 除了Exception以外, 因为 e是将异常分配给变量所必需的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM