def getStuff(x):
return 'stuff'+x
def getData(x):
return 'data'+x
thefunctions = []
thefunctions.append("getStuff")
thefunctions.append("getData")
for i in thefunctions:
print i('abc')
Run Code Online (Sandbox Code Playgroud)
这可能吗?谢谢.
Jon*_*erg 12
thefunctions = [ getStuff, getData ]
for f in thefunctions:
print f('shazam')
Run Code Online (Sandbox Code Playgroud)
完成def语句后,您已将名称与函数关联.只需使用该名称即可引用该功能.