write in multiple files python
fn = open("path of input file.txt","r")
fnew = fn.read()
fs = fnew.split('\n')
for value in fs:
f = [open("path of output file to write.txt" %i,'w') for i in range(len(list_of_files))]
f.write(value)
f.close()
3.5
10
154,135
151,147
236.244
Thank you!
10
0
3.7
10
fn = open("path of input file.txt","r")
for i, line in enumerate(fn):
f = open("/home/vidula/Desktop/project/ori_tri/input_%i.data" %i,'w')
f.write(line)
f.close()
Thank you!
10
0
4
10
"['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']"
Thank you!
10
0
4.67
3
128,129
116,118
108,104
Thank you!
3
0
Are there any code examples left?
New code examples in category Python
-
Python 2023-04-11 03:04:20
-
Python 2022-03-27 22:40:04 pycharm no module named
-
Python 2022-03-27 22:25:05 assign multiple variablesin one line
-
Python 2022-03-27 22:20:02 levenshtein distance
-
Python 2022-03-27 21:35:09 get text from url python last slash
-
Python 2022-03-27 21:30:30 df concatenate df
-
Python 2022-03-27 21:25:09 python odd or even
-
Python 2022-03-27 21:15:32 python include function from another file
-
Python 2022-03-27 21:10:01 color module python
-
Python 2022-03-27 21:00:27 python tkinter cursor types