Python2.7中的数据结构
我想将我的数据结构转换为:Python2.7中的数据结构,python,python-2.7,data-structures,iterator,Python,Python 2.7,Data Structures,Iterator,我想将我的数据结构转换为: names=['Peter', 'John'] size = ['M', 'L'] list_price = [[1, 2], [4, 5]] 带有标价的名称为您完成了大部分工作: [{'size_price': [1,2],'size':['M','L'], 'name': 'Peter'}, {'size_price': [4,5],'size':['M','L'], 'name': 'John'}] 这是一种不同的数据结构。你能再看一下数据吗?谢谢!
names=['Peter', 'John']
size = ['M', 'L']
list_price = [[1, 2], [4, 5]]
带有标价的名称为您完成了大部分工作:
[{'size_price': [1,2],'size':['M','L'], 'name': 'Peter'},
{'size_price': [4,5],'size':['M','L'], 'name': 'John'}]
这是一种不同的数据结构。你能再看一下数据吗?谢谢!!现在可以了!
result = []
for name, prices in zip(names, list_price):
result.append({"name": name, "size_price": prices, "size": size})