从路径列表中确定字典列表

2024-10-02 14:23:39 发布

您现在位置:Python中文网/ 问答频道 /正文

嘿,伙计们,我是python的新手,我必须解决这个问题。我有一个文件,其中收集了一些变量路径,例如:

Simulation/Task Information Variables/Periodic Task 1/Task Call Counter

Simulation/Task Information Variables/Periodic Task 1/Task Turnaround Time

Simulation/Task Information Variables/RTILINMM_MAIN_LINID1INTERRUPT/Task Call Counter

Simulation/Application Startup Variables/Scaled Time Interval

Model/CON/Bus_Selector_Mapping/Bus\nCreator/Out1{SubArray1}

Model/NEW_CPT_TA/CAN/DCTM/ESS/Value

Labels/BCM{Occurence4}{SubArray14}

Labels/Ign4{SubArray6}

BusSystems/CON/Master/GE/RX/GE_ID

我必须生成一个字典列表,如下所示:

[{PAR1: [Simulation, Model, Labels, BusSystems]},{PAR2: [Simulation, [Task Information Variables,Application Startup Variables]}, {PAR3: [CON, Model, [NEW_CPT_TA]}

第一个字典包含父元素的列表,列表的第二个包含{PAR1: [Simulation, Model, Labels, BusSystems]}中第一个元素的子元素,标签为Simulation。我很抱歉在格式错误,但这是我在这里的第一篇文章。谢谢大家帮助我


Tags: 元素列表tasklabelsmodelinformationtimeapplication