我可以通過從要存儲的數組名稱生成文件名來循環執行此操作嗎?在python中獲取數組變量
ab = array.array('B', map(operator.xor, a, b))
f1 = open('ab', 'wb')
ab.tofile(f1)
f1.close
ac = array.array('B', map(operator.xor, a, c))
f1 = open('ac', 'wb')
ac.tofile(f1)
f1.close
ad = array.array('B', map(operator.xor, a, d))
f1 = open('ad', 'wb')
ad.tofile(f1)
f1.close
ae = array.array('B', map(operator.xor, a, e))
f1 = open('ae', 'wb')
ae.tofile(f1)
f1.close
af = array.array('B', map(operator.xor, a, f))
f1 = open('af', 'wb')
af.tofile(f1)
f1.close
謝謝你的幫助!
他們是在一個字典 - 它被稱爲*當地人()* :) – 2010-03-10 21:34:04
@伊恩是的,但有些人不喜歡使用它,因爲它是一種黑客。 – 2010-03-10 21:50:21
謝謝!如果a,b,c,d,e,f也是數組,那麼這樣做嗎? – lclevy 2010-03-10 21:53:31