本文整理汇总了Python中timer.Timer.call_after方法的典型用法代码示例。如果您正苦于以下问题:Python Timer.call_after方法的具体用法?Python Timer.call_after怎么用?Python Timer.call_after使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类timer.Timer
的用法示例。
在下文中一共展示了Timer.call_after方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print
# 需要导入模块: from timer import Timer [as 别名]
# 或者: from timer.Timer import call_after [as 别名]
print(message.format(*args, now=now))
def one(timer):
format_time("{now}: Called One")
def two(timer):
format_time("{now}: Called Two")
def three(timer):
format_time("{now}: Called Three")
class Repeater:
def __init__(self):
self.count = 0
def repeater(self, timer):
format_time("{now}: repeat {0}", self.count)
self.count += 1
timer.call_after(5, self.repeater)
timer = Timer()
timer.call_after(1, one)
timer.call_after(2, one)
timer.call_after(2, two)
timer.call_after(4, two)
timer.call_after(3, three)
timer.call_after(6, three)
repeater = Repeater()
timer.call_after(5, repeater.repeater)
format_time("{now}: Starting")
timer.run()
开发者ID:Dennitizer,项目名称:Python_Master-the-Art-of-Design-Patterns,代码行数:32,代码来源:1261_07_26_timer_test.py
示例2: format_time
# 需要导入模块: from timer import Timer [as 别名]
# 或者: from timer.Timer import call_after [as 别名]
from timer import Timer
import datetime
def format_time(message, *args):
now = datetime.datetime.now().strftime("%I:%M:%S")
print(message.format(*args, now=now))
class Repeater:
def __init__(self):
self.count = 0
def __call__(self, timer):
format_time("{now}: repeat {0}", self.count)
self.count += 1
timer.call_after(5, self)
timer = Timer()
timer.call_after(5, Repeater())
format_time("{now}: Starting")
timer.run()
开发者ID:trenton3983,项目名称:Python3_Object_Oriented_Programming,代码行数:25,代码来源:1261_07_28_callable_repeat.py