How to overwrite the previous print to stdout in python?

后端 未结 16 1435
别那么骄傲
别那么骄傲 2020-11-22 09:46

If I had the following code:

for x in range(10):
     print x

I would get the output of

1
2
etc..

What I

16条回答
  •  -上瘾入骨i
    2020-11-22 10:24

    This works on Windows and python 3.6

    import time
    for x in range(10):
        time.sleep(0.5)
        print(str(x)+'\r',end='')
    

提交回复
热议问题