python 实现定时循环触发某个方法

直接贴上代码

import threading 
def sayhello(): 
        print "hello world" 
        global t        #Notice: use global variable! 
        t = threading.Timer(5.0, sayhello) 
        t.start() 
   
t = threading.Timer(5.0, sayhello) 
t.start() 

线程t不断的改变

posted @ 2015-09-02 22:30  孙悟坑  阅读(2602)  评论(0编辑  收藏  举报