Carriage Return not working in IDLE?

前端 未结 2 888
情深已故
情深已故 2020-12-10 15:12

I\'m trying to create a code for a countdown timer that stays in place: so that each line overwrites the previous one. This is what I have so far:

import tim         


        
相关标签:
2条回答
  • 2020-12-10 15:34

    When \r doesn't work, try \x08 (backspace), and add the flush=True to be safe:

    print('\x08' * 5 + timeformat, end='', flush=True)
    
    0 讨论(0)
  • 2020-12-10 15:52

    IDLE doesn't support most control characters such as \r, \b. It is still true in 2020 (no support in Python 3.9)

    \r should work if you start Python REPL in a Unix terminal or in Windows console instead.

    0 讨论(0)
提交回复
热议问题