Implementation Method of Python function periodical execution, python periodic
This article describes how to implement Python functions periodically. We will share this with you for your reference. The details are as follows:
The sched module of python is required:
# Coding = utf-8import time, sched, OS # initialize sched class of sched Module # The first parameter is a function that returns a timestamp, and the second parameter can be blocked before the timing does not arrive. S = sched. scheduler (time. time, time. sleep) # function def event_func (): print "Current Time:", time. time () # enter: interval event, priority (used for simultaneous execution of two events that arrive at the same time), and called function, parameters (Note: tuple must be used for example, if there is only one parameter (xx,) def perform (inc): s. enter (inc, 0, perform, (inc,) event_func () def mymain (inc = 60): s. enter (0, 0, perform, (inc,) s. run () # if _ name _ = "_ main _": # mymain ()