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 - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -