作爲Python的新手,我一直試圖想出構建多維字典/數組的代碼。如何構建一個多維詞典
輸入數據由csv字段組成,第一行用'<'字符表示。我需要在 「目標」 和 「產品」 字段鍵:
0:轉,1:目標名稱,2:產品名稱,3:svn的轉速,4:時間/日期 < 1,RAM,卡特邁,7416,1373386517.0,2013-07-09十五點15分17秒-0700>
0:區域名稱,1:開始地址,2:結束地址,3:等 LOAD_REGION2,0x0000004C,0x000003B4 ,92.6,7.4 LOAD_REGION2,0x0002152C,0x0001E6D4,47.7,52.3 LOAD_REGION2,0x0002EECC,0x00013034,28.8,71.2 < 1,ROM,卡特邁,7416,1373386517.0,2013-07-09 15點15分17秒-0700> LOAD_REGION2,0x0000004C,0x000003B4,92.6,7.4 LOAD_REGION2,0x00005CEC,0x00039F14,90.9,9.1 LOAD_REGION2,0x00003A78,0x0003E488,94.5,5.5 < 1,RAM,烤麪包機,7416,1373386517.0,2013-07-09 15:15 :17 -0700> LOAD_REGION0,0x000000B8,0x00000348,82.0,18.0 LOAD_REGION0,0x0000AD10,0x00014EF0,65.9,34.1 LOAD_REGION1,0x00005244,0x00008CBC,63.1,36.9 LOAD_REGION3,0x00002A50,0x000FD5B0,99.0,1.0 LOAD_REGION3,0x000135B4, 0x00000E4C,4.4,95.6 LOAD_REGION3,0x00000000,0x07B00000,100.0,0.0 < 1,ROM,烤麪包機,7416,1373386517.0,2013-07-09 15時15分17秒-0700> LOAD_REGION0,0x000000B8,0x00000348,82.0,18.0 LOAD_REGION0,0x00008710,0x000174F0,73.4,26.6 LOAD_REGION1,0x00003B6C,0x0000A394,73.4,26.6 LOAD_REGION3,0x00000208,0x000FFDF8,100.0,0.0 LOAD_REGION3,0x00000000,0x00014400,100.0,0.0 LOAD_REGION3,0x00000000,0x07B00000,100.0,0.0
我想要讀取每條記錄並構建一個數組,主目錄字段的索引和次要索引是產品字段。 [目標名稱] [產品名稱] [「1」] = 7416,1373386517.0,2013-07-09 15:15:17 -0700 [目標名稱] [產品名稱] [「2」] [區域名稱] = 0x0000004C,0x000003B4,92.6,7.4
什麼是構建字典的正確方法?或者我應該使用多維列表數組?