python 定时任务

import datetime

from threadingimport Timer

def time_printer():

    now = datetime.datetime.now()

    ts = now.strftime('%Y-%m-%d %H:%M:%S')

    print('do func time :', ts)

def loop_monitor(times, fun):

    t =Timer(times, fun)

    t.start()

loop_monitor(5, time_printer)

你可能感兴趣的:(python 定时任务)