python - Why is it not writing a new line with every result? -


im trying write results text file, i've got write text file i'm trying write new line can add result,

while true:   results = read_temp()   f = open('results.txt','w')   f.truncate()   f.write(str(results) + '\n')   f.write('\n')   f.close()   print results    time.sleep(1) 

but i'm getting @ moment 1 result in text file

(20.0, 68.0) 

this result

(20.0, 68.0) 

is print results or preview in e.g. notepad output file ?

remember differents of new line unix/windows in files(!)

and why truncate in loop ?


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -