通过增加一个整数来增加符号的数量 (python)

increase the amount of symbols by increasing an integer (python)

我正在尝试显示所用时间的指示器,我想显示进度条。

这是我当前的代码:

time = time * 60
time = time / 100
x = 0
while x < 101:
    per = chr(ord('█') + int(x))
    per_ = chr(ord(' ') + int(100 - x))
    await asyncio.sleep(time)
    pr = (f'\rTime used: |{str(per)}{str(per_)}| {x}%')
    print(pr, end="\r")
    x = x + 1

但我得到的只是奇怪的符号组合。我真的不知道如何正确使用 chr 或 ord

> Time used: |▐ ↑| 8%

chrord 在字符和表示该特定字符的整数之间进行转换。你不需要在这里使用它们。

此外,* 用于重复字符串(而不是 +)。

像这样的东西应该可以工作:

per = '█' * int(x)
per_ = ' ' * int(100 - x))