1
鑑於這些數據跳繩線間歇性地在Python
Probes FOO BAR
Organ BM LV
Genes Gene1 Gene2
1452463_x_at 306.564 185.705
1439374_x_at 393.742 330.495
1426392_a_at 269.850 209.931
我想跳過打印頭兩行與器官和基因開始。 我試圖做的是:
with open('my_data.txt','r') as tsvfile
tabreader = csv.reader(tsvfile,delimiter = '\t')
for row in tabreader:
if ["Genes","Organ"] in row:
continue
print row
但爲什麼失敗?
最終所需的輸出是這樣的:
Probes FOO BAR
1452463_x_at 306.564 185.705
1439374_x_at 393.742 330.495
1426392_a_at 269.850 209.931
在Python,它更容易只是negaate用'not'函數的聲明。例如,你可能會考慮使用表達式:'如果行[0]不是(「基因」,「器官」):打印row' – ssm