【发布时间】:2018-11-26 11:39:51
【问题描述】:
我有一个变量可以是int 或None。如果是别的,我会报错。
我有以下代码:
if not isinstance(id, int) or id is not None:
raise AttributeError('must be called with a id of type INT or NONE')
这是行不通的,因为每个条件都会否定另一个条件,并且总是会引发错误。
【问题讨论】:
-
当您需要时,德摩根的法律规范在哪里...
-
给你:deMorgan
标签: python python-3.x python-3.5 python-3.6