How to use timer in Python
This article mainly introduces how to use timer in Python, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.
Using timers in Python
Today, I see a more humanized timing module schedule. At present, the number of star is 6432, which is still very popular. This module also adheres to the principle of For Humans.
1. It can be installed through pip.
Pip install schedule
two。 Use case
Import scheduleimport timedef job (): print ("Ilemm working...") schedule.every (10) .minutes.do (job) schedule.every (). Hour.do (job) schedule.every (). Day.at ("10:30") .do (job) schedule.every (). Monday.do (job) schedule.every (). Wednesday.at ("13:15") .do (job) schedule.every (). Minute.at ("17") .do (job) while True : schedule.run_pending () time.sleep (1)
From the literal meaning of the word, you know what it is for.
For example:
Schedule.every () monday.do (job)
This code function is the meaning of the word, the timer will run the function job every Monday, how is it very simple?
Thank you for reading this article carefully. I hope the article "how to use timer in Python" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!