Re: [问题] 怎么用 Python 写出 switch 的功能?

楼主: mikapauli (桜花)   2017-10-19 20:18:07
使用dict的方法:
def f0():
...
def f1():
...
def f2():
...
...
switch = {'c0': 0, 'c1': 1, 'c2': 2, ...}
process = (f0, f1, f2, ...)
...
[f() for f in process[switch[case]:]]

Links booklink

Contact Us: admin [ a t ] ucptt.com