我遇到一个我编写的简单程序的问题,我想根据用户输入执行某个功能.我已经使用字典作为交换机的替代来进行分配,但是当我尝试将字符分配给字典时,它不会执行它们...代码:
def PrintValuesArea():
## do this
def PrintValuesLength():
## do that
def PrintValuesTime():
## do third
PrintTables={"a":PrintValuesArea,"l":PrintValuesLength,"t":PrintValuesTime}
PrintTables.get(ans.lower()) ## ans is the user input
Run Code Online (Sandbox Code Playgroud)
我做错了什么?它看起来和我见过的所有例子都一样....
python ×1