我有一个枚举来表示函数的不同可能值。
class A(Enum):
NOT_FOUND = NONE
INAQUATE = NONE
POSITIVE = 1
# Some more
但是,当从函数返回此枚举时,
def search_function(target = 1):
if target == 1:
return A.INAQUATE
else:
return A.POSITIVE
返回 ,而不是将程序分解为行。A.NOT_FOUNDA.INAQUATE
Python 3.7.6
>>> from enum import Enum
>>> class A(Enum):
... NOT_FOUND = None
... INAQUATE = None
... POSITIVE = 1
...
>>> def search_function(target = 1):
... if target == 1:
... return A.INAQUATE
... return A.NOT_FOUND
...
>>> search_function()
<A.NOT_FOUND: None>
有没有办法正确返回?A.INAQUATE
慕妹3242003
相关分类