I don't understand why I cannot write to file in my python program. I have list of strings measurements. I want just write them to file. Instead of all strings it writes only 1 string. I cannot understand why.
This is my piece of code:
fmeasur = open(fmeasur_name, 'w')
line1st = 'rev number, alg time\n'
fmeasur.write(line1st)
for i in xrange(len(measurements)):
fmeasur.write(measurements[i])
print measurements[i]
fmeasur.close()
I can see all print of these trings, but in the file there is only one. What could be the problem?
only onedo you mean all of them are in the same line without any newline? In such a case you have to append a newline with each write to the filexrangeto iterate throughtmeasurementsyou should just usefor item in measurementsor if you need the indexfor index,item in enumerate(measurements)