在python中,有时候有大量数据需要处理,有一个很大的for循环,可能处理起来很慢。若是每次循环,都用print 打印内容,那么会导致打印超级多的内容,很麻烦。那么如果有个进度条,显示起来就非常方便了。
那么,可以采用如下代码:
另外,还可以利用Python的工具包,progressbar,首先安装progressbar包,pip install progressbar
what is rational is actual and what is actual is rational.
凡是合理的都是存在的,凡是存在的都是合理的。
那么,可以采用如下代码:
import sys
for i in range(0,10000):
percent = 1.0 * i / 10000
sys.stdout.write("%.4f"%percent)
sys.stdout.write("%\r")
sys.stdout.flush()
参考了博客http://www.jb51.net/article/123829.htm另外,还可以利用Python的工具包,progressbar,首先安装progressbar包,pip install progressbar
from progressbar import ProgressBar
pbar = ProgressBar()
for i in pbar(range(0,10000)):
do something
参考博客:http://blog.topspeedsnail.com/archives/6238what is rational is actual and what is actual is rational.
凡是合理的都是存在的,凡是存在的都是合理的。