How to rewrite output in terminal

后端 未结 4 1020
孤城傲影
孤城傲影 2020-12-25 13:22

I have a Python script and I want to make it display a increasing number from 0 to 100% in the terminal. I know how to print the numbers on the terminal but how can I \"rewr

4条回答
  •  春和景丽
    2020-12-25 13:46

    Using the blessings package - clear your screen (clear/cls) and enter:

    import sys
    from blessings import Terminal
    from time import sleep # <- boy, does this sound tempting a.t.m.
    
    term = Terminal()
    for i in range(6):
        with term.location(term.width - 3, term.height - 3):        
            print('{}'.format(i))
        sleep(2)
        if (i == 3):
            print('what was I doing, again?')
    print('done')
    

    To install it from CheeseShop, just...

    pip install blessings
    

提交回复
热议问题