def bar():
i = 0
while i < 100:
i += 1
time.sleep(1)
sys.stdout.write(str(i) + '\b'*2)
#sys.stdout.write(' \b')
sys.stdout.flush()
#此代码输出后是光标不断往前走的效果..
def bar():
i = 0
while i < 100:
i += 1
time.sleep(1)
sys.stdout.write(str(i) + '\b'*2)
#sys.stdout.write(' \b')
sys.stdout.flush()
#此代码输出后是光标不断往前走的效果..
我才你想要的是 '\r' —— '\r' 的作用是 “回到行首”。