我有一个脚本,它使用一个简单的 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
它似乎在“p.render ...”处循环,并且不会返回“print 'Processing %d of %d ...'”。
更新:我很抱歉。似乎 ProgressBar.render() 在渲染进度条时删除了“print 'Processing...”的输出。进度条来自http://nadiana.com/animated-terminal-progress-bar-in-python