终端python中的文本重叠

时间:2019-05-27 02:06:16

标签: python python-3.x terminal ubuntu-14.04

当我用\ r打印进度条时,文本重叠了

for i in range(1000000):
    cal = int(i * 0.3 * 92 / 1000000)
    text = "\r {}/{} {}>overlapped".format(fmt_bytes(i),
                                           fmt_bytes(1000000),
                                           "=" * cal)
    sys.stdout.write(text)
    sys.stdout.flush()

输出与以下相同:

50.56 kB/976.56 kB =>overlappedpped

如何解决?

0 个答案:

没有答案