7 Antworten
+ 5
# will execute the inside part at exactly 15:00:00
import datetime
while True:
t = datetime.datetime.now()
if t.hour == 15 and t.minute == 0 and t.second == 0:
# Your code here
+ 2
𝕿𝖍𝖊 𝕲𝖗𝖊𝖆𝖙 𝕾𝖆𝖌𝖆 Sure, if it is enough to check every minute, time.sleep(60) will do.
Just so it is clear -- the CPU allocation will be minimal. I used to have a simple daily routine checker ran in this way on the "baby Pi" and it worked smoothly :)
+ 1
Just put the code inside an infinite while loop and check for the current time with a frequency you need.
+ 1
ohh..thank you Kuba Siekierzyński bro
+ 1
Kuba Siekierzyński The code you have written will keeps CPU busy. Don't you think we can add sleep according to user interest?
0
plz explain it in more detail Kuba Siekierzyński
0
Kuba Siekierzyński Thanks