0.摘要
本文主要介绍在python3环境下使用progress库显示程序运行进度条。
python3中安装progress:pip install progressbar2
python2中安装progress:pip install progressbar
1.三个步骤
progressbar的基础步骤为:start,update,finish
start(max_value=None, init=True):Starts measuring time, and prints the bar at 0%。
update(value=None, force=False, **kwargs): Updates the ProgressBar to a new value。
finish(end='\n') :Puts the ProgressBar bar in the finished state。
import progressbar
def fun(n):
if n == 1 or n == 2:
return 1
else:
return fun(n-1) + fun(n-2)
if __name__ == '__main__':
p = progressbar.ProgressBar()
max_value = 100