看板 Python 關於我們 聯絡資訊
※ 引述《huggie (huggie)》之銘言: : iterate 一個 list 的時候.. : a = [1,2,3,4] : 可以用 : for i in a: : print a : 也可以用 : for i in xrange(len(a)): : print a[i] : 但我忘了那第三個方法是什麼了..最近才發現的.. : 以前都用第二個方法 : 第三個也很好用的.. def echo(s): print s a = [1,2,3,4] [echo(item) for item in a] map(echo, a) 像這樣嗎? 不過print好死不死好像不能當成lambda -- VICTOR工作室 http://www.kinmen.info/vic/ 程式設計教學 http://victorlin.serveftp.org/programming/ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 125.231.218.77