0

如下面发布的代码所示。尽管打印语句显示的值为visualizationOperationID2,这意味着elif应该执行该语句,但是如下面的输出部分所示,两者areaOfCoverageVisOpValueaveragHeightsVisOpValue都设置为 False!!我所期望的是,根据 和 的值visualizationOperationID averagHeightsVisOpValue分别areaOfCoverageVisOpValue应该是 False 和 True 。

你能帮我实现我期望发生的事情吗?请问有什么问题。

代码

areaOfCoverageVisOpValue = False
averagHeightsVisOpValue = False

if (visualizationOperationID == VisualizationOperations.visOpAverageHeight):
    averagHeightsVisOpValue = True
    areaOfCoverageVisOpValue = False
elif (visualizationOperationID == VisualizationOperations.visOpAreaOfCoverage):
    averagHeightsVisOpValue = False
    areaOfCoverageVisOpValue = True

print(visualizationOperationID)
print(VisualizationOperations.visOpAverageHeight)
print(VisualizationOperations.visOpAreaOfCoverage)
print(averagHeightsVisOpValue)
print(areaOfCoverageVisOpValue)
exit()

可视化操作类

class VisualizationOperations(Enum):
visOpAverageHeight = 1
visOpAreaOfCoverage = 2

def __str__(self):
    return '{0}'.format(self.value)
    

输出

2
1
2
False
False
4

0 回答 0