0
すべての反復に対して新しい配列(またはリスト)を作成したいと思います。ここに私のコードは次のとおりです。Pythonはforループの異なる反復のために新しい配列を作成します
import numpy as np
data2 = open('pathways.dat', 'r', errors = 'ignore')
pathways = data2.readlines()
special_line_indexes = []
PWY_ID = []
line_cont = []
L_PRMR = [] #Left primary
#i is the line number (first element of enumerate), while line is the line content (2nd elem of enumerate)
for CUI in just_compound_id:
for i,line in enumerate(pathways):
if '//' in line:
#fint the indexes of the lines containing //
special_line_indexes = i+1
elif 'REACTION-LAYOUT -' in line:
if CUI in line:
PWY_ID.append(special_line_indexes)
具体的に私はCUI(最初foorループ)の異なる反復のための異なるアレイPWY_IDを作成したいです。私が終わるのは、すべての出力を持つ長い配列です。おそらく、辞書を使う方が効率的でしょうが、forループでそれを実装する方法がわかりません。