Here is some of the auto generate code to set alarm using python playsound library. I encountered some problem where the iteration only read the first time string on array time1 or time2 when the actual time came. My intention is to make sure the alarm pop up for all the specified time1 and time2 with different sound. Anyone got an idea???. Thanks
from playsound import playsound
import time
timestr=time.strftime('%H%M')
print timestr
time1=['0903','1003','1103','1203']
time2=['0933','1033','1133','1233']
for x,y in zip(time1,time2):
if timestr==x:
playsound('D:/METAR/open-web/sound1.mp3')
break
elif timestr==y:
playsound('D:/METAR/open-web/sound2.mp3')
break
else:
playsound('D:/METAR/open-web/sound3.mp3')
break
break
Aucun commentaire:
Enregistrer un commentaire