May-07-2018, 12:09 PM
Hi all, since I'm new in Python, sorry for my easy question but I'd like to open new files in a loop lets say 4 new files which are writable and defined in a loop using for i in range(0,4) and then I want to write some data inside of them.
For example, if I had an only file named as controlpointsdata, the below code is ok
Best Regards,
Ahmet
For example, if I had an only file named as controlpointsdata, the below code is ok
f=open("controlpointsdata","w")but now I have 4 files and I want it to be written as
a=[i for i in range(0,4)]
f=[0 for i in range(0,4)]
for i in range(0,4): f[i]=open("controlpointsdata_i","w") f[i].write(a[i]) f[i].close()The question is how could I open the files named as ctrlptdata_0, ctrlptdata_1, ctrlptdata_2,ctrlptdata_3 since the above code does not work correctly.
Best Regards,
Ahmet