當前位置:編程學習大全網 - 網站源碼 - python的計時器

python的計時器

妳可以用Twisted來實現,源代碼如下:

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搜搜載壹個裝了就可以了。

  • 上一篇:Php網站小程序源代碼
  • 下一篇:高端大氣的英文微信網站名稱,高質量翻譯成英文網站名稱。
  • copyright 2024編程學習大全網