Python Multiple File Writing Question
I need python to write multiple file names, each file name is different than the last. I have it writing in a for loop. Therefore the data files written from the Python program sho
Solution 1:
Alternatively using with
for i inrange(10):
withopen('data%i.txt' %i, 'w') as f:
f.write('whatever')
with
takes care of closing the file if something goes wrong. This could be especially important if you are creating files in a for loop,
Post a Comment for "Python Multiple File Writing Question"