2015-04-07 79 views
0

我有这样如何将哈希键数组的python哈希转换为数组?

products = {'results': {'images': 'http://static13.jassets.com/p/Gini-26-Jony-Green-Casual-Shirt-9007-7386721-4-zoom.jpg', 'offers': {}, 'name': ['\n   Green Casual Shirt  '], 'features': {}, 'brand': ['\n   Gini & Jony  ']}} 

的Python字典,我怎么能转换图像键给数组?

现在图像是像

{'images': 'http://static13.jassets.com/p/Gini-26-Jony-Green-Casual-Shirt-9007-7386721-4-zoom.jpg'} 

但我想图像是一个数组

{'images': ['http://static13.jassets.com/p/Gini-26-Jony-Green-Casual-Shirt-9007-7386721-4-zoom.jpg','','','','']} 

回答

0

尝试使用名单理解:

products['results']['images'] = [products['results'][v] for v in products['results'] if v == 'images']