python for循环显示进度

from progressbar import Percentage, ProgressBar,Bar,ETA

bar = ProgressBar(widgets=[Bar('>', '[', ']'), ' ', Percentage(), ' ', ETA()],maxval=len(im_files))


其中im_files为要循环的目标,如:

for im_file in bar(im_files):


另一种简单方法

import time
N = 1000
for i in range(N):

    print("progress:{0}%".format(round((i + 1) * 100 / N)), end="\r")

#python2情况下为

#print "progress:{0}%\r".format(round((i + 1) * 100 / N)),

#,表示不换行

    time.sleep(0.01)

猜你喜欢

转载自blog.csdn.net/scut_salmon/article/details/79660099