的data
,dic
和abst
是列表,在形式的數據:[[0, 1, 0, 0 , 1...0],[1, 0, 0, 1, 0, 1....0]]
,在循環之後,我得到的結果是這樣的:如何單獨打印列表而不是合併它們?
abst = ['PS50802', 'PS50803', 'PS50804', 'PS50805', 'PS50806', 'PS50807', 'PS50808', 'PS50809', 'PS50810', 'PS50811', 'PS50812', 'PS50813', 'PS50814',......]
dic = ['PS50102' 'PS50101' 'PS50106' 'PS50199' 'PS50196' 'PS00832' 'PS50072'...]
[0.0, 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0, 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0, 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0, 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0]
看起來像兩個單獨的列表合併成一個列表,但是怎麼可以我得到的結果是這樣的:
[0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0, 0.0,0.0,0.0,0.0, 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0, ,[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0, ,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0]]
lines = []
for x in range(0, 2):
for item in dic:
for i,j in enumerate(abst):
if item == j:
lines.append(data[x][i])
print lines
你能解決你的第二個結果?它缺少一個括號 –
你可以發佈你的數據,dic和abst變量的簡化版本,並確切地說明你想要實現的目標嗎? – CoMartel
@HarryPotfleur,是的,我做到了。 – Kun