1. Timer
def hello(name):
print 'hello world, i am %s, Current time: %s' % (name, time.time())
hello = partial(hello, 'guo')
t = Timer(3, hello)
t.start()
但是只执行一次,想办法做成一个真正的定时器:
def hello(name):
global t
t = Timer(3, hello)
t.start()
print 'hello world, i am %s, Current time: %s' % (name, time.time())
hello = partial(hello, 'guo')
t = Timer(3, hello)
t.start()
2. sched
def hello(name):
print 'hello world, i am %s, Current Time:%s' % (name, time.time())
s = sched.scheduler(time.time, time.sleep)
s.enter(3, 2, hello, ('guo',))
s.run()
和Timer是一样的效果,再修改:
def hello(name):
print '