<p>我找到了这段代码,它应该说明枚举是如何工作的。我知道现在在Python3中情况有所不同,但我想理解这个示例。我需要输入什么才能执行<code>print("You chose the easy option")</code></p>
<p>我试过<code>1</code>、<code>Easy</code>和<code>Choice.Easy</code>到目前为止都没有成功</p>
<pre><code>def enum(**enums):
return type('Enum', (), enums)
Choice = enum(Easy = 1, Medium = 2, Hard = 3)
choice = input("Enter choice: ")
if choice == Choice.Easy:
print("You chose the easy option")
elif choice == Choice.Medium:
print("You chose the medium option")
elif choice == Choice.Hard:
print("You chose the hard option")
else:
print("You should choose one of the three levels!")
</code></pre>