猿问

请教:Python如何快速简单地将如下a转换成b,谢谢!

a=[{'id':374, 'name': 'Human Resources', 'parent_id': [372, 'Human Resources'], 'sequence':0},
{'id': 386, 'name': 'Time Tracking','parent_id': [372, 'Human Resources'], 'sequence': 5},
{'id': 387, 'name': 'Attendances','parent_id': [372, 'Human Resources'], 'sequence': 10}]
b=[(374, 0,'Human Resources', 372), (386, 5, 'Time Tracking', 372), (387, 10,'Attendances', 372)]

ITMISS
浏览 80回答 1
1回答

holdtom

[(x['id'],x['sequence'],x['name'],x['parent_id'][1]) for x in a]
随时随地看视频慕课网APP

相关分类

Python
我要回答