2011-05-05 73 views

回答

5

使用list comprehension

i = 1 
data = [[1,10],[2,20],[3,30]] 
result = [d[i] for d in data] # [10, 20, 30] 

也可參閱list comprehension vs. map這個問題。

+0

或適合原始問題'result = [x [i] for x in l]' – 2011-05-05 00:17:43

+0

FYI列表理解比map更高度優化。 – jathanism 2011-05-05 00:51:22

相關問題