-2
http://pastebin.com/zTMwBKUnは、forループのリストに要素を追加 - ネストされたループ
私はトラブル私のDjangoのコードによって読み込まれますリストを作成するを抱えています。これは、Pythonの問題だが、djangoではない。
for line in reader:
date = datetime.datetime.strptime(line[0], '%m/%d/%Y').date()
各行は、[0]、日付オブジェクトにと、おそらくそれを可能デシベルモデルの検証設定にもかかわらず、投入する必要があり、私はすべてのブランク値はそれをインポートしてもらうためにゼロになるようにする必要があります。
for entry in line:
row = []
entry = make_int(entry)
row.append(entry)
これが出力されます:
['4/24/2016'] - This needs to be replaced with the 'date' vairable from pastebin
['A320']
['623NK']
['LAX-ORD']
['1']
['4.4']
[0]
[0]
[0]
[0]
[0]
['4.4']
['4.4']
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
[0]
出力は次のようになりする必要があります:それは、次のDjangoのコードで読み取ることができるようにするため
[date, A320, 623NK, LAX-ORD, etc... ]
:
# f = Flight(
# date = date,
# aircraft = row[1],
# aircraft_ident = row[2],
# route = row[3],
# legs = row[4],
# duration = row[5],
# landings_day = int(row[6]),
# landings_night = row[7],
# night = row[8],
# instrument = row[9],
# approaches = row[10],
# cross_country = row[11],
# second_in_command = row[12],
# pilot_in_command = row[13],
# simulated_instrument = row[14],
# instructor = row[15],
# dual = row[16],
# remarks = row[17],
# simulator = row[18],
# solo = row[19],
# flight_cost = row[20],
# expenses = row[21],
# )
# f.save()
外部リンクではなく、質問本体にコードを入力してください。そして、覚えておいて、それは[mcve] –