python定时器(Timer)用法简单实例

WBOY
Release: 2016-06-10 15:10:48
Original
2076 people have browsed it

本文实例讲述了python定时器(Timer)用法。分享给大家供大家参考。具体如下:

# encoding: UTF-8
import threading
#Timer(定时器)是Thread的派生类,
#用于在指定时间后调用一个方法。
def func():
  print 'hello timer!'
timer = threading.Timer(5, func)
timer.start()

Copy after login

该程序可实现延迟5秒后调用func方法的功能。

希望本文所述对大家的Python程序设计有所帮助。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!