静态控制台进度栏PYTHON

时间:2019-01-27 01:11:10

标签: python static console line progress

问题: 如何使此进度栏仅在命令行末尾打印,以便我可以继续在控制台中打印 elestuff >?

我制作了一个进度条,下面是源代码:

def progressbar(percentage, info=''):

    if percentage > float(0.99):
        percentage = 1.0
    percent = 100 * percentage

    if percent > 2:
        percent /= 2

    percent = int(percent) + 1
    perstr = "█"
    for _ in range(percent):
        perstr += "█"

    print("%{:.2f} {}{:51.51}{} {:17.17}".format(percentage*100, "[", perstr, "]", info), end='\r')

结果是这样的: %91.04 [████████████████████████████████████████████████ ]信息部分

*想起kali linux控制台进度栏*

0 个答案:

没有答案