xinghe0 发表于 2018-8-26 08:08:23

python 制作Shell下面的进度条

制作Shell下面的进度条
  来源地址:http://snipperize.todayclose.com/snippet/py/%E5%88%B6%E4%BD%9CShell%E4%B8%8B%E9%9D%A2%E7%9A%84%E8%BF%9B%E5%BA%A6%E6%9D%A1--33351/
  


[*]def _flushWid2info(self):
[*]      self._sql = "select count(*) as total from test"
[*]      total = self._mysql.findOne(self._sql)['total']   #找到总数
[*]
[*]      self._mysql.freeResult()
[*]      self._sql = "select * from test"
[*]      self._mysql.query(self._sql)
[*]      _tmp = self._mysql.findNext()
[*]      i = 0.0
[*]      while _tmp:
[*]            sys.stdout.write("%4d%% %d" % ((i / total) * 100, i) + "\b" * (6 + len(str(int(i))))) #相除得出进度 \b 就是退格
[*]            _tmp = self._mysql.findNext()
[*]            i += 1
[*]      _tmp = None
  



页: [1]
查看完整版本: python 制作Shell下面的进度条