I want to write a function in Python that returns different fixed values based on the value of an input index.
(我想用Python编写一个函数,该函数根据输入索引的值返回不同的固定值。)
In other languages I would use a switch
or case
statement, but Python does not appear to have a switch
statement.
(在其他语言中,我将使用switch
或case
语句,但是Python似乎没有switch
语句。)
What are the recommended Python solutions in this scenario? (在这种情况下,推荐的Python解决方案是什么?)
ask by Michael Schneider translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…