我有一个包含 196 个列表的文件,我想创建新的 196 个输出文件并将每个列表写入一个新文件,这样我将有 196 个输出文件,每个输出文件包含 1 个输入数据列表 这是输入文件:
"['128,129', '116,118', '108,104', '137,141', '157,144', '134,148', '138,114', '131,138', '248,207', '208,247', '246,248', '101,106', '131,115', '119,120', '131,126', '138,137', '132,129']"
"['154,135', '151,147', '236,244', '243,238', '127,127', '125,126', '122,124', '123,126', '127,129', '122,121', '147,134', '126,132', '128,137', '233,222', '222,236', '125,126']"
.....例如,我只给出了 2 个列表,但总共有 196 个列表。输出应该是:
文件 1:
128,129
116,118
108,104
文件2:
154,135
151,147
236.244
当前代码:
fn = open("/home/vidula/Desktop/project/ori_tri/inpt.data","r")
fnew = fn.read()
fs = fnew.split('\n')
for value in fs:
f = [open("/home/vidula/Desktop/project/ori_tri/input_%i.data" %i,'w') for i in range(len(list_of_files))]
f.write(value)
f.close()
错误:列表不属性写入。