Sunday, October 08, 2023

simple way to overwrite text in terminal using python

https://stackoverflow.com/questions/4897359/output-to-the-same-line-overwriting-previous-output
 

just add , end='\r' to the print()

So, something like the code in this private repo,
https://github.com/hn-88/python-tuya-fadein-web/

while i > 10:
      d.set_brightness_percentage(i, nowait)
      print("d brightness {0:3d}".format(i))
      b.set_brightness_percentage(i, nowait)
      print("b brightness {0:3d}".format(i), end='\r')
      moveup(1)
      sleep(1)
      i -= 10

No comments:

Post a Comment