反射小例子
import sys def func(): print('xxx' * 100) def func1(): print('yyy' * 100) l = [('xxx功能', 'func'), ("yyy功能", 'func1')] for ind, f_tup in enumerate(l, 1): print(ind, f_tup[0], f_tup[1]) num = int(input('num : ')) getattr(sys.modules[__name__], l[num - 1][1])()