Python Use Switch Case?
This question already has an answer here:
Python does not implement a switch
. An alternative is using a dict like so:
def func1():
pass
def func2():
pass
switch = {
"do1": func1,
"do2": func2,
}
do_str = "do1"
switch[do_str]()
链接地址: http://www.djcxy.com/p/42764.html
下一篇: Python使用开关盒?