我尝试了其他问题中提到的所有脚本,但对我不起作用。
for x in range (0,10):
print(x, end='\r', flush=True)
print(x, sep='\r', end='', flush=True)
print('\r', x)
请对此提供帮助。
答案 0 :(得分:2)
您可能想覆盖文本,对吧?
您需要写退格键以删除最后一行,然后打印下一行。 查看此帖子以获取示例:How to create a spinning command line cursor?
答案 1 :(得分:1)
也许,您希望connection = await aio_pika.connect_robust(
"amqp://guest:guest@127.0.0.1/", loop=loop
)
async with connection:
# ...
使用time.sleep(1)
具有更好的可视化效果:
stdout.write
输出:
答案 2 :(得分:1)
>>> for x in range(10):
... print('\r', x, end='')
...
9>>>
如您所见,由于回车符号\r
,所有其他数字均被覆盖。