Newbie Code Question


I’m new to python and I’m trying to modify an script but I cant get it to do what I want. Hope anyone can give me a clue here.

So; I’m trying to use the end=’\r’ code to replace the print output for the line showed below.

print("{0:0.1f}".format(temperature, humidity))

This is the unmodified output;


What I need is to instead of print the result in multiple lines, I need the new value to replace the old value on the same line. Only one line.

Any help will be appreciate.

That ought to work. What I suspect isn’t happening is the implicit
flush-on-newline behaviour, because you’re no longer ending lines with a
newline. Adding flush=True to the print options will test that for you.

The stdout stream is normally line buffered when directed to a terminal,
but a “line” is delimited by a newline character. For timely updates, if
you’re not using that character, you need to flush the buffer at the end
of the print().

Cameron Simpson