0
所以我试图用sys.stdout.write()
重写它所在的当前行,并用不同的文本替换它。但我希望这发生在多行输出。更新多条输出线
# I am looking at having 2 lines with changing values in them that will keep over writing themselves without moving any further down.
import sys
for i in range(10):
sys.stdout.write("\r" + "Hello" + str(i) + "\n + "Hello" + str(i) * 2)
sys.stdout.flush()
我试过这个,但每次碰到\ n它都会在不清除所有内容的情况下无限增加行数。
(不要担心把你的帖子标为“不紧急” - 无论如何,这里没有任何紧急事件,所以我修剪了它)。 – halfer