我正在尝试编写一个Python程序,每隔一定时间就会播放一次声音,但它并没有真正起作用。当我测试代码并到达指定的时间时,它将永远重复播放声音。
以下是代码:
以下是代码:
import os
from datetime import datetime
now = datetime.now()
currentHour = now.hour
currentMin = now.minute
#I also tested with if but it didn't work
while currentHour==15 and currentMin==33:
os.system("aplay /home/pi/sound.wav") #Plays the sound thru aplay
cron
或Windows任务计划程序。 - jfs