- 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
本文转自阿汐 51CTO博客,原文链接:http://blog.51cto.com/axiii/301204,如需转载请自行联系原作者