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

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -