当我要求pycharm运行它时,程序的所有内容都有效。
但当我问我的覆盆子Pi运行它时,它会跳过EndTimer
。所以这首歌继续播放。在Windows上,歌曲会停止。什么能让这个小小的差异?
import datetime
import pygame
def Clockupdate(time):
Timer = "21:56:00"
EndTimer = '21:56:20'
if time == Timer:
playsound()
if time == EndTimer:
global a
a = False
def secondrefresher():
newtime = ""
oldtime = datetime.datetime.now()
a = str(oldtime.hour)
b = str(oldtime.minute)
c = str(oldtime.second)
if int(c) < 10:
c = "0"+str(c)
if int(b) < 10:
b = "0"+str(b)
curtime = (a+":"+b+':'+c)
if curtime != newtime:
newtime = curtime
Clockupdate(newtime)
def playsound():
pygame.mixer.init()
pygame.mixer.music.load("ABTPP.mp3")
pygame.mixer.music.play()
global a
a = True
while a:
secondrefresher()