想了想能不能不换行再加上进度条呢,于是在google上搜了一阵还真有这个包 在这里 再封装一下
#!/usr/bin/python2
#auth:codewalker #mail:001@codewalker.me
#version 0.2
#date 2013-10-20
from time import sleep
from progressbar import ETA,ProgressBar,Bar, Percentage
class timer:
def __init__(self, sec=10):
self.sec = sec
def main(self, sec):
widgets = [Bar(‘>’),
Percentage(),
“ “,
ETA()]
pbar = ProgressBar(widgets=widgets, maxval=(self.sec+1)10).start()
for i in range(1,self.sec10):
sleep(0.1)
pbar.update(i+1)
pbar.finish()
def start(self):
self.main(self)
if __name__ == “__main__“:
t = timer(5)
t.start()