lines = [(1, 1, '父1节点'), (2, 1, '1-2'), (3, 1, '1-3'), (4, 3, '1-3-4'), (5, 3, '1-3-5'), (6, 3, '1-3-6'), (7, 7, '父7节点'), (8, 7, '7-8'), (9, 7, '7-9')] nodes = {} data_temp =[] for line in lines: id, parentId, name = line nodes[id] = {'} # orLeafnode