python之timer0.3

想了想应该用参数的话更好些加入getopt包 #!/usr/bin/python2 #auth:codewalker #mail:001@codewalker.me #version 0.3 #date 2013-10-20 from time import sleep from progressbar import ETA,ProgressBar,Bar, Percentage import getopt import sys class timer: def __init__(self, sec): 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.sec+1)*10): sleep(0.1) pbar.update(i+1) pbar.finish() def start(self): self.main(self) def USAGE(): […]

python之timer0.2

想了想能不能不换行再加上进度条呢,于是在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.sec*10): sleep(0.1) pbar.update(i+1) pbar.finish() def start(self): self.main(self) if __name__ == “__main__”: […]

python之timer

坐那感觉心跳厉害想测一下心率写了个定时很简单 #!/usr/bin/python2 #auth:codewalker #mail:001@codewalker.me #version 0.1 #date 2013-11-20 from time import sleep def main(): for i in range(1,60): print i sleep(1) if __name__ == “__main__”: main()