![](/img/trans.png)
[英]How do I input a list into a function and recieve a list in Python?
[英]How do I do this in Python? List to function
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')
這可能嗎? 謝謝。
thefunctions = [ getStuff, getData ]
for f in thefunctions:
print f('shazam')
完成def
語句后,您將名稱與函數關聯起來。 只需使用該名稱即可引用該功能。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.