005-基础-使用字典实现菜单功能,同时调用相应的函数

005-基础-使用字典实现菜单功能,同时调用相应的函数

 1 def syncdb():
 2     print ("syncdb.....")
 3 def stop_server(name):
 4     print("%s stop server....." %(name))
 5 
 6 actions = {
 7     'stop': stop_server,
 8     'syncdb': syncdb,
 9 }
10 
11 actions["stop"]("wj")




原文地址:https://www.cnblogs.com/zhidian2020/p/14011048.html