我想知道如何采摘所有水果,例如:
[['id', 'sub type', 'type'], ['1', 'apples', 'fruit'], ['15', 'orange', 'fruit'], ['3', 'corn', 'vegtable']]
如何输出:
['sub type','apple','orange','corn']
请您参考如下方法:
像 list comprehension 一样简单:
>>> lst = [['id', 'sub type', 'type'], ['1', 'apples', 'fruit'], ['15', 'orange', 'fruit'], ['3', 'corn', 'vegtable']]
>>> [x[1] for x in lst]
['sub type', 'apples', 'orange', 'corn']
>>>
