首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

twisted-简略启动

2012-10-27 
twisted-简单启动from twisted.internet import reactorimport timedef printTime():print current time

twisted-简单启动

from twisted.internet import reactorimport timedef printTime():    print "current time is",time.strftime("%H:%M:%S")    def stopReactor():    print "stopping reactor"    reactor.stop()reactor.callLater(1,printTime)reactor.callLater(2,printTime)reactor.callLater(3,printTime)reactor.callLater(4,printTime)reactor.callLater(5,stopReactor)print "Running the reactor...."reactor.run()print "Reacotr stopped."

?

?

?reactor.callLater函数的第一个参数是要等待的秒,第二个参数是要调用的函数,后面还可以跟着参数,就是调用函数的参数

>>>
Running the reactor....
current time is 21:04:09
current time is 21:04:10
current time is 21:04:11
current time is 21:04:12
stopping reactor
Reacotr stopped.
>>>

热点排行