【发布时间】:2017-07-02 19:42:21
【问题描述】:
我需要的是获取变量的东西,如果变量是函数的名称,则将调用该函数。 我不是想从模块中获取函数,而是从程序本身中获取函数
例子:
def foo():
print("Foo")
callfunction = input("What function do you want to call? ")
callfunction() ## Not sure what to put here but but lets say callfunction is foo.
我不想要这样的东西,因为我有很多功能:
if callfunction == "Foo"
Foo()
else:
print("No function with that name")
我的问题类似于this,但我要求提供 Python 语法。我正在使用 Python 3.5.1
【问题讨论】:
标签: python python-3.x