from twisted.internet import task
from twisted.internet import reactor
#set global variables
g = 0
def run():
global g
g = g + 1
print 'the global value g is:%s'%g
#add function run to twisted's looping call
l = task.LoopingCall(run)
#set interval to 5*60 seconds
l.start(5*60)
reactor.run()
要運行這段代碼妳得裝twisted和zope中關於interface的定義,上google搜搜載壹個裝了就可以了。