# encoding: UTF-8 import threading #Timer(定时器)是Thread的派生类, #用于在指定时间后调用一个方法。 def func(): print 'hello timer!' timer = threading.Timer(5, func) timer.start()
该程序可实现延迟5秒后调用func方法的功能。
希望本文所述对大家的Python程序设计有所帮助。