1
14 2015-04-22 01:12:48 +08:00 1
func_map = {
'print_a': print_a, 'print_b': print_a, } s = 'print_a' func = func_map[s] |
2
Sylv 2015-04-22 01:17:03 +08:00 via iPhone 2
|
3
gateswong 2015-04-22 01:17:48 +08:00 2
|
4
DaVinci42 OP |
5
twor2 2015-04-22 01:48:22 +08:00
```
input() uses raw_input to read a string of data, and then attempts to evaluate it as if it were a Python program, and then returns the value that results. So entering ``` |
6
wizardforcel 2015-04-22 08:19:31 +08:00 via Android
动态调用么。用eval吧
funcName ="print_a" eval(funcName)() |
7
JoeShu 2015-04-22 10:03:24 +08:00
应该安装1楼的方式,用字典代替switch语句,其他的输入直接执行和调用eval的都不要信,会有很严重的安全问题。
|