I have a list of dictionaries that all have the same structure within the list. For example:
test_data = [{'id':1, 'value':'one'}, {'id':2, 'value':'two'}, {'id':3, 'value':'three'}]
I want to get each of the value
items from each dictionary in the list:
['one', 'two', 'three']
I can of course iterate through the list and extract each value using a for loop:
results = []
for item in test_data:
results.append(item['value'])
however my data set is quite large. I'm wondering if there's a faster way to this.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…