循环行为时帮助Python

Fra*_*cis 1 python while-loop

我有一个脚本,使用一个简单的while循环来显示进度条,但它似乎没有像我预期的那样工作:

count = 1
maxrecords = len(international)
p = ProgressBar("Blue")
t = time
while count < maxrecords:
    print 'Processing %d of %d' % (count, maxrecords)
    percent = float(count) / float(maxrecords) * 100
    p.render(int(percent))
    t.sleep(0.5)
    count += 1
Run Code Online (Sandbox Code Playgroud)

它似乎在"p.render ..."循环,并且不会回到"打印'处理%d的%d ...'".

更新:我的道歉.ProgressBar.render()在呈现进度条时会删除"print'Processing ..."的输出.进度条来自http://nadiana.com/animated-terminal-progress-bar-in-python

Nad*_*mli 5

我看到你在我的网站上使用ProgressBar实现.如果要打印消息,可以在render中使用message参数

p.render(percent, message='Processing %d of %d' % (count, maxrecords))
Run Code Online (Sandbox Code Playgroud)