0
私のクラス割り当ては、ある行のテキストファイルから新しいテキストファイルに各行をコピーするコードを書くことです。私は私の頭を壁にぶつけすぎて、もう私が見ているものを見ることができないように感じる。ここでpythonのあるファイルから別のファイルに行をコピーする
は私が持っているものです。
source_file = open('data1.txt', 'r')
line = numbers_file.readline()
destination_file = open('data2.txt', 'w')
source_file.seek(0)
for line in source_file:
destination_file.writelines(line)
source_file.close()
destination_file.close()
'destination_file.writelinesループなし(ライン)' => 'destination_file.write(ライン)' –
または 'destination_file.writelines(のsource_file)' –
'numbers_file'とは何ですか?あなたはそれを決して定義しません、そしてあなたはそれから読みとられた価値を使用しません。 – chepner