import os
import sys
a = os.listdir("C:\\Python27\\forms2")
i = 0
big_file = open("c:\\Python27\\forms2\\%s" %a[i], 'r')
small_file3 = open("c:\\Python27\\forms3\\%s" %a[i], 'w')
linez = big_file.read()
for line in linez:
if 'TextControl' in linez:
small_file3.write(line)
if 'http://' in linez:
small_file3.write(line)
i = i + 1
big_file.close()
small_file3.close()
出力は
Traceback (most recent call last):
File "C:\Python27\testreadwrite", line 13, in <module>
small_file3.write(line)
ValueError: I/O operation on closed file
「testreadwrite」はスクリプトの名前です。「a」リスト変数を注入する必要がある場所に注入するのはなぜですか?