凌的博客

您现在的位置是: 首页 > 学无止境 > python > 

python

python 定时器(timer)

2018-10-12 python 1096
#! /usr/bin/python3
#! -*- conding: utf-8 -*-

import threading
import time

def fun_timer():

    print(time.strftime('%Y-%m-%d %H:%M:%S'))
    global timer
    timer = threading.Timer(2,fun_timer)
    timer.start();


timer = threading.Timer(1,fun_timer)
timer.start();



time.sleep(15)
timer.cancel()

文章评论

0条评论