python progressbar 在进度条中添加自己动态的信息(防止花眼)
import progressbar
import time
widgets = ['进度:',
progressbar.Percentage(), ' ',
progressbar.Bar('='),' ',
progressbar.Timer(), ' ',
progressbar.DynamicMessage("training_batch_acc"),
]
bar=progressbar.ProgressBar(widgets=widgets, max_value=1000)
for i in range(1000):
time.sleep(1)
bar.dynamic_messages.training_batch_acc = 10
bar.update(i)
代码中 training_batch_acc为自己添加的动态信息,通过widgets设置变量,dynamic_messages.training_batch_acc修改值,可实时动态显示,简洁明了