我有一個像下面這樣的列表。根據項目值創建一個新列表
['T46', 'T43', 'R45', 'R44', 'B46', 'B43', 'L45', 'L44', 'C46', 'C45']
,我想組根據int值:
[id][' ',' ',' ',' ',' '] # AREA PATTERN [Top, Right, Bottom, Left, Center]
[46]['1','0','1','0','1'] #Top,Bottom,Center
[45]['0','1','0','1','1'] #Right,Left,Center
[43]['1','0','1','0','0'] #Top,Bottom
[44]['0','1','0','1','0'] #Right,Left
這可能嗎?我到目前爲止所嘗試的是:
id_area = []
for a in area:
id = a[1:3]
areas = a[:1]
if any(str(id) in s for s in area):
id_area = #lost
該列表中的項目如何與您的組示例相關聯? –
哦..所以這兩個數字是組,然後第一個字符是標誌... gotcha –