[問題]如何迭代函數中的參數
請各位高手指點一下
我現在的腳本大概是這樣...
def a(path):
do_something
def b(path):
do_anotherthing
if __name__ == "__main__":
path = raw_input('path:')
a(path)
b(path)
假設這個path是/home/a/test那一切都ok
問題是我現在想要連同/home/b/test跟/home/c/test都一並處理,
卻不要更動函數裡已經寫好的東西,
而是迭代函數中的參數
寫成像是:
mypath = glob.glob('/home/*/test')
for path in mypath:
def a(path):
do_something
def b(path):
do_anotherthing
當然這樣是行不通的,我已經google過closure跟類
不知道我這種情況比較適合用什麼方法?
謝謝!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 123.193.212.162
→
01/18 19:43, , 1F
01/18 19:43, 1F
→
01/18 20:45, , 2F
01/18 20:45, 2F
→
01/18 20:45, , 3F
01/18 20:45, 3F
Python 近期熱門文章
PTT數位生活區 即時熱門文章